Jelajahi Sumber

Fixed a problem where the default error message text used in IE wasn't showing up as being translated.

Added a new string, and changed the code to explicitly use it instead of the one supplied by the browser.
James Albright 7 tahun lalu
induk
melakukan
4b077ac006

+ 1 - 0
server/src/main/java/password/pwm/i18n/Display.java

@@ -161,6 +161,7 @@ public enum Display implements PwmDisplayBundle {
     Display_SetupOtp_iPhone_Steps,
     Display_SetupOtp_iPhone_Steps,
     Display_SetupOtp_Other_Title,
     Display_SetupOtp_Other_Title,
     Display_SetupOtp_Other_Steps,
     Display_SetupOtp_Other_Steps,
+    Display_SetupOtp_VerificationCodeFormat,
     Display_WarnExistingOtpSecretTime,
     Display_WarnExistingOtpSecretTime,
     Display_WarnExistingOtpSecret,
     Display_WarnExistingOtpSecret,
     Display_WarnExistingResponseTime,
     Display_WarnExistingResponseTime,

+ 1 - 0
server/src/main/resources/password/pwm/i18n/Display.properties

@@ -168,6 +168,7 @@ Display_SetupOtp_iPhone_Title=iPhone
 Display_SetupOtp_iPhone_Steps=<b>On your iPhone, tap the App Store icon.</b><ol><li>On your phone, go to the App Store.</li><li>Search for <b>Google Authenticator</b>.<br/>(<a target\="itunesstore" href\="https\://itunes.apple.com/us/app/google-authenticator/id388497605?mt\=8">Download from the App Store</a>)</li><li>Tap the app, and then tap Free to download and install it.</li></ol><b>Next, open and configure Google Authenticator.</b><ol><li>In Google Authenticator, tap "+", and then "Scan Barcode."</li><li>Use your phone's camera to scan this barcode.</li><li>Once you have scanned the barcode, click the continue button.</li></ol>
 Display_SetupOtp_iPhone_Steps=<b>On your iPhone, tap the App Store icon.</b><ol><li>On your phone, go to the App Store.</li><li>Search for <b>Google Authenticator</b>.<br/>(<a target\="itunesstore" href\="https\://itunes.apple.com/us/app/google-authenticator/id388497605?mt\=8">Download from the App Store</a>)</li><li>Tap the app, and then tap Free to download and install it.</li></ol><b>Next, open and configure Google Authenticator.</b><ol><li>In Google Authenticator, tap "+", and then "Scan Barcode."</li><li>Use your phone's camera to scan this barcode.</li><li>Once you have scanned the barcode, click the continue button.</li></ol>
 Display_SetupOtp_Other_Title=Other
 Display_SetupOtp_Other_Title=Other
 Display_SetupOtp_Other_Steps=<b>Find a compatible two-factor app.</b><ul><li>Try searching your device's app store for <b>Google Authenticator</b>.<br/>Many devices have compatible apps.</li><li>Try looking for an app that supports "<b>TOTP security tokens"</b> or "RFC6238"</li><li>Download and install the application.</li></ul><b>Next, open and configure the app.</b><ol><li>Enter the data below or scan the code as the app instructs.</li><li>Once you have configured the app, click the continue button.</li></ol>
 Display_SetupOtp_Other_Steps=<b>Find a compatible two-factor app.</b><ul><li>Try searching your device's app store for <b>Google Authenticator</b>.<br/>Many devices have compatible apps.</li><li>Try looking for an app that supports "<b>TOTP security tokens"</b> or "RFC6238"</li><li>Download and install the application.</li></ul><b>Next, open and configure the app.</b><ol><li>Enter the data below or scan the code as the app instructs.</li><li>Once you have configured the app, click the continue button.</li></ol>
+Display_SetupOtp_VerificationCodeFormat=The verification code must be 6 numeric digits.
 Display_TokenDestination=Token Destination
 Display_TokenDestination=Token Destination
 Display_TokenResend=Your security code should arrive right away.  If you have waited for a while and haven't yet received a code, click the resend code button to receive a new code.
 Display_TokenResend=Your security code should arrive right away.  If you have waited for a while and haven't yet received a code, click the resend code button to receive a new code.
 Display_UsernameHeader=@User\:ID@
 Display_UsernameHeader=@User\:ID@

+ 11 - 0
server/src/main/webapp/WEB-INF/jsp/setupotpsecret-test.jsp

@@ -22,6 +22,9 @@
 
 
 <%@ page import="password.pwm.http.bean.SetupOtpBean" %>
 <%@ page import="password.pwm.http.bean.SetupOtpBean" %>
 <%@ page import="password.pwm.http.tag.conditional.PwmIfTest" %>
 <%@ page import="password.pwm.http.tag.conditional.PwmIfTest" %>
+<%@ page import="password.pwm.i18n.Display" %>
+<%@ page import="password.pwm.util.LocaleHelper" %>
+<%@ page import="org.apache.commons.lang3.StringEscapeUtils" %>
 <!DOCTYPE html>
 <!DOCTYPE html>
 <%@ page language="java" session="true" isThreadSafe="true"
 <%@ page language="java" session="true" isThreadSafe="true"
          contentType="text/html" %>
          contentType="text/html" %>
@@ -73,6 +76,14 @@
     PWM_GLOBAL['startupFunctions'].push(function() {
     PWM_GLOBAL['startupFunctions'].push(function() {
         PWM_MAIN.addEventHandler('button-goback','click',function(){PWM_MAIN.handleFormSubmit(PWM_MAIN.getObject('goBackForm'))});
         PWM_MAIN.addEventHandler('button-goback','click',function(){PWM_MAIN.handleFormSubmit(PWM_MAIN.getObject('goBackForm'))});
         document.getElementById("<%= PwmConstants.PARAM_OTP_TOKEN%>").focus();
         document.getElementById("<%= PwmConstants.PARAM_OTP_TOKEN%>").focus();
+
+        <%--Calling setCustomValidity allows us to set a custom error message on the input field--%>
+        PWM_MAIN.addEventHandler('<%= PwmConstants.PARAM_OTP_TOKEN%>', 'input', function (event) {
+            event.target.setCustomValidity("");
+        });
+        PWM_MAIN.addEventHandler('<%= PwmConstants.PARAM_OTP_TOKEN%>', 'invalid', function (event) {
+            event.target.setCustomValidity("<%=StringEscapeUtils.escapeEcmaScript(LocaleHelper.getLocalizedMessage(Display.Display_SetupOtp_VerificationCodeFormat, JspUtility.getPwmRequest(pageContext)))%>");
+        });
     });
     });
 </script>
 </script>
 </pwm:script>
 </pwm:script>