From 95bffdfb14ee5a6114946e5ce2e8b005f336450d Mon Sep 17 00:00:00 2001 From: shekhar16 Date: Fri, 3 May 2024 23:13:00 +0530 Subject: [PATCH] fix(oxtrust): password mismatch error on registration page Signed-off-by: shekhar16 --- .../gluu/oxtrust/action/RegisterPersonAction.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/gluu/oxtrust/action/RegisterPersonAction.java b/server/src/main/java/org/gluu/oxtrust/action/RegisterPersonAction.java index f95b2bea7..da7e9935f 100644 --- a/server/src/main/java/org/gluu/oxtrust/action/RegisterPersonAction.java +++ b/server/src/main/java/org/gluu/oxtrust/action/RegisterPersonAction.java @@ -520,10 +520,12 @@ 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; } @@ -531,13 +533,22 @@ public void validateConfirmPassword(FacesContext context, UIComponent comp, Obje 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,