Bläddra i källkod

Fixed a problem where the required LDAP Attributes regular expression error message does not show message to user.

When adding a Required LDAP Attribute to a forgotten password authentication, the Regular Expressions Error Message did not appear when the regular expression is not met.

Steps to reproduce:
Go to
Config Editor | Modules | Public | Forgotten Password | Profiles | default | Definition
Add a required LDAP Attribute and click Options.
Add a regular expression and a failure message.
Add the LDAP Attribute to one of the Optional Required authentication methods.
Try to use the forgotten password module as a user.
Input a response that does not match the regular expression.
Click "Check Answers"

Expected results:
The regular expression custom error message should appear on the screen in some way.

Actual results:
A bubble pops up with the text "Please match the requested format"
James Albright 7 år sedan
förälder
incheckning
51fdffd88b
1 ändrade filer med 15 tillägg och 0 borttagningar
  1. 15 0
      server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp

+ 15 - 0
server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp

@@ -15,6 +15,7 @@
 <%@ page import="password.pwm.http.PwmRequestAttribute" %>
 <%@ page import="java.util.Collections" %>
 <%@ page import="password.pwm.config.CustomLinkConfiguration" %>
+<%@ page import="org.apache.commons.lang3.StringEscapeUtils" %>
 
 <%--
   ~ Password Management Servlets (PWM)
@@ -141,6 +142,20 @@
         </script>
     </pwm:script>
     <% } %>
+    <% if (loopConfiguration.getRegexError(formLocale) != null && loopConfiguration.getRegexError(formLocale).length() > 0) { %>
+    <pwm:script>
+        <script type="text/javascript">
+            PWM_GLOBAL['startupFunctions'].push(function(){
+                PWM_MAIN.addEventHandler('<%=loopConfiguration.getName()%>', 'input', function (event) {
+                    event.target.setCustomValidity("");
+                });
+                PWM_MAIN.addEventHandler('<%=loopConfiguration.getName()%>', 'invalid', function (event) {
+                    event.target.setCustomValidity('<%=StringEscapeUtils.escapeEcmaScript(loopConfiguration.getRegexError(formLocale))%>');
+                });
+            });
+        </script>
+    </pwm:script>
+    <% } %>
     <pwm:script>
         <script type="text/javascript">
             PWM_GLOBAL['startupFunctions'].push(function(){