Skip to content

Commit

Permalink
fix(oxtrust): fix password mismatch error on registration of a user
Browse files Browse the repository at this point in the history
Signed-off-by: shekhar16 <shekharlaad1609@gmail.com>
  • Loading branch information
shekhar16 committed May 3, 2024
1 parent fe2c29e commit 800921a
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 800921a

Please sign in to comment.