Search in sources :

Example 1 with RegistrationRequiredValidationError

use of org.summerb.approaches.springmvc.security.ve.RegistrationRequiredValidationError in project summerb by skarpushin.

the class UsersServiceFacadeImpl method validateUserIsEligableForPasswordReset.

protected void validateUserIsEligableForPasswordReset(String email) throws FieldValidationException {
    ValidationContext ctx = new ValidationContext();
    if (!ctx.validateEmailFormat(email, User.FN_EMAIL)) {
        throw new FieldValidationException(ctx.getErrors());
    }
    // now see if this user exists
    UserStatus userStatus = getUserStatusByEmail(email);
    if (userStatus == UserStatus.NotExists || userStatus == UserStatus.Provisioned) {
        throw new FieldValidationException(new RegistrationRequiredValidationError());
    }
    // Sanity check
    if (userStatus != UserStatus.NormalUser && userStatus != UserStatus.AwaitingActivation) {
        throw new RuntimeException("Password Reset scenario is not supported for user whose status is: " + userStatus);
    }
}
Also used : FieldValidationException(org.summerb.approaches.validation.FieldValidationException) RegistrationRequiredValidationError(org.summerb.approaches.springmvc.security.ve.RegistrationRequiredValidationError) UserStatus(org.summerb.approaches.springmvc.security.dto.UserStatus) ValidationContext(org.summerb.approaches.validation.ValidationContext)

Aggregations

UserStatus (org.summerb.approaches.springmvc.security.dto.UserStatus)1 RegistrationRequiredValidationError (org.summerb.approaches.springmvc.security.ve.RegistrationRequiredValidationError)1 FieldValidationException (org.summerb.approaches.validation.FieldValidationException)1 ValidationContext (org.summerb.approaches.validation.ValidationContext)1