Search in sources :

Example 1 with NoSuchVerificationTokenException

use of org.craftercms.profile.exceptions.NoSuchVerificationTokenException in project profile by craftercms.

the class ProfileServiceImpl method verifyProfile.

@Override
public Profile verifyProfile(String verificationTokenId, final String... attributesToReturn) throws ProfileException {
    VerificationToken token = verificationService.getToken(verificationTokenId);
    if (token == null) {
        throw new NoSuchVerificationTokenException(verificationTokenId);
    }
    Profile profile = updateProfile(token.getProfileId(), profileUpdater -> {
        profileUpdater.setEnabled(true);
        profileUpdater.setVerified(true);
    }, attributesToReturn);
    verificationService.deleteToken(verificationTokenId);
    logger.debug(LOG_KEY_PROFILE_VERIFIED, profile.getId());
    return profile;
}
Also used : NoSuchVerificationTokenException(org.craftercms.profile.exceptions.NoSuchVerificationTokenException) VerificationToken(org.craftercms.profile.api.VerificationToken) Profile(org.craftercms.profile.api.Profile)

Example 2 with NoSuchVerificationTokenException

use of org.craftercms.profile.exceptions.NoSuchVerificationTokenException in project profile by craftercms.

the class ProfileServiceImpl method changePassword.

@Override
public Profile changePassword(String resetTokenId, final String newPassword, final String... attributesToReturn) throws ProfileException {
    VerificationToken token = verificationService.getToken(resetTokenId);
    if (token == null) {
        throw new NoSuchVerificationTokenException(resetTokenId);
    }
    Profile profile = updateProfile(token.getProfileId(), profileUpdater -> profileUpdater.setPassword(CryptoUtils.hashPassword(newPassword)), attributesToReturn);
    verificationService.deleteToken(resetTokenId);
    logger.debug(LOG_KEY_PASSWORD_CHANGED, profile.getId().toString());
    return profile;
}
Also used : NoSuchVerificationTokenException(org.craftercms.profile.exceptions.NoSuchVerificationTokenException) VerificationToken(org.craftercms.profile.api.VerificationToken) Profile(org.craftercms.profile.api.Profile)

Aggregations

Profile (org.craftercms.profile.api.Profile)2 VerificationToken (org.craftercms.profile.api.VerificationToken)2 NoSuchVerificationTokenException (org.craftercms.profile.exceptions.NoSuchVerificationTokenException)2