Skip to content

Commit

Permalink
fix(oxtrust): password mismatch error on registration page
Browse files Browse the repository at this point in the history
Signed-off-by: shekhar16 <[email protected]>
  • Loading branch information
shekhar16 committed May 3, 2024
1 parent fe2c29e commit 8cb2307
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,24 +520,35 @@ public void validateConfirmPassword(FacesContext context, UIComponent comp, Obje
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(message);
}
boolean validateOnlyPwd = false;
AttributeValidation validation = attributeService.getAttributeByName("userPassword").getAttributeValidation();
boolean canValidate = validation != null && validation.getRegexp() != null && !validation.getRegexp().isEmpty();
if (comp.getClientId().endsWith("password")) {
this.password = (String) value;
validateOnlyPwd = true;
} else if (comp.getClientId().endsWith("passwordValidation")) {
this.repeatPassword = (String) value;
}
this.repeatPassword = this.repeatPassword == null ? "" : this.repeatPassword;
if (canValidate) {
pattern = Pattern.compile(validation.getRegexp());
}
if (!StringHelper.equalsIgnoreCase(password, repeatPassword) && this.repeatPassword != null) {

if (canValidate && validateOnlyPwd
&& (!pattern.matcher(this.password).matches())) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
facesMessages.evalResourceAsString("#{msgs['password.validation.invalid']}"),
facesMessages.evalResourceAsString("#{msgs['password.validation.invalid']}"));
context.addMessage(comp.getClientId(context), message);
}
if (!validateOnlyPwd && !StringHelper.equals(password, repeatPassword) && this.repeatPassword != null) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage("Both passwords should be the same!");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(message);
}
if (canValidate
if (canValidate && !validateOnlyPwd
&& (!pattern.matcher(this.password).matches() || !pattern.matcher(this.repeatPassword).matches())) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
Expand Down

0 comments on commit 8cb2307

Please sign in to comment.