use of edu.harvard.iq.dataverse.confirmemail.ConfirmEmailInitResponse in project dataverse by IQSS.
the class Admin method startConfirmEmailProcess.
/**
* This method is used in integration tests.
*
* @param userId The database id of an AuthenticatedUser.
*/
@Path("confirmEmail/{userId}")
@POST
public Response startConfirmEmailProcess(@PathParam("userId") long userId) {
AuthenticatedUser user = authSvc.findByID(userId);
if (user != null) {
try {
ConfirmEmailInitResponse confirmEmailInitResponse = confirmEmailSvc.beginConfirm(user);
ConfirmEmailData confirmEmailData = confirmEmailInitResponse.getConfirmEmailData();
return ok(Json.createObjectBuilder().add("tokenCreated", confirmEmailData.getCreated().toString()).add("identifier", user.getUserIdentifier()));
} catch (ConfirmEmailException ex) {
return error(Status.BAD_REQUEST, "Could not start confirm email process for user " + userId + ": " + ex.getLocalizedMessage());
}
}
return error(Status.BAD_REQUEST, "Could not find user based on " + userId);
}
Aggregations