use of edu.harvard.iq.dataverse.confirmemail.ConfirmEmailData in project dataverse by IQSS.
the class DataverseUserPage method showVerifyEmailButton.
/**
* Determines whether the button to send a verification email appears on user page
* @return
*/
public boolean showVerifyEmailButton() {
final Timestamp emailConfirmed = currentUser.getEmailConfirmed();
final ConfirmEmailData confirmedDate = confirmEmailService.findSingleConfirmEmailDataByUser(currentUser);
return (!getUserAuthProvider().isEmailVerified()) && confirmedDate == null && emailConfirmed == null;
}
use of edu.harvard.iq.dataverse.confirmemail.ConfirmEmailData in project dataverse by IQSS.
the class AuthenticationServiceBean method deleteAuthenticatedUser.
/**
* Use with care! This method was written primarily for developers
* interested in API testing who want to:
*
* 1. Create a temporary user and get an API token.
*
* 2. Do some work with that API token.
*
* 3. Delete all the stuff that was created with the API token.
*
* 4. Delete the temporary user.
*
* Before calling this method, make sure you've deleted all the stuff tied
* to the user, including stuff they've created, role assignments, group
* assignments, etc.
*
* Longer term, the intention is to have a "disableAuthenticatedUser"
* method/command. See https://github.com/IQSS/dataverse/issues/2419
*/
public void deleteAuthenticatedUser(Object pk) {
AuthenticatedUser user = em.find(AuthenticatedUser.class, pk);
if (user != null) {
ApiToken apiToken = findApiTokenByUser(user);
if (apiToken != null) {
em.remove(apiToken);
}
ConfirmEmailData confirmEmailData = confirmEmailService.findSingleConfirmEmailDataByUser(user);
if (confirmEmailData != null) {
/**
* @todo This could probably be a cascade delete instead.
*/
em.remove(confirmEmailData);
}
userNotificationService.findByUser(user.getId()).forEach(userNotificationService::delete);
AuthenticationProvider prv = lookupProvider(user);
if (prv != null && prv.isUserDeletionAllowed()) {
prv.deleteUser(user.getAuthenticatedUserLookup().getPersistentUserId());
}
actionLogSvc.log(new ActionLogRecord(ActionLogRecord.ActionType.Auth, "deleteUser").setInfo(user.getUserIdentifier()));
em.remove(user.getAuthenticatedUserLookup());
em.remove(user);
}
}
use of edu.harvard.iq.dataverse.confirmemail.ConfirmEmailData 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