Search in sources :

Example 1 with RegistrationRequiredValidationError

use of org.summerb.webappboilerplate.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.validation.FieldValidationException) RegistrationRequiredValidationError(org.summerb.webappboilerplate.security.ve.RegistrationRequiredValidationError) UserStatus(org.summerb.webappboilerplate.security.dto.UserStatus) ValidationContext(org.summerb.validation.ValidationContext)

Aggregations

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