[ChangePassword] Applied code review.
authorJonathan Bueno <jonathan.bueno@openbravo.com>
Mon, 22 Feb 2016 11:31:04 +0100
changeset 28681 d31f552b21a4
parent 28680 e0aaaa3f6b1b
child 28682 bd8ecbb28bd0
[ChangePassword] Applied code review.

Now client messages are translated.
Used === for javascript comparison
src-db/database/sourcedata/AD_MESSAGE.xml
src/org/openbravo/erpCommon/security/Login.html
src/org/openbravo/erpCommon/security/Login.java
src/org/openbravo/erpCommon/security/Login.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Fri Feb 19 13:42:53 2016 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Mon Feb 22 11:31:04 2016 +0100
@@ -19286,6 +19286,18 @@
 <!--47D88149F6D2473D892D25F4A86CA161-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--47D88149F6D2473D892D25F4A86CA161--></AD_MESSAGE>
 
+<!--47FE48A07B1F404DBC023F4303999919--><AD_MESSAGE>
+<!--47FE48A07B1F404DBC023F4303999919-->  <AD_MESSAGE_ID><![CDATA[47FE48A07B1F404DBC023F4303999919]]></AD_MESSAGE_ID>
+<!--47FE48A07B1F404DBC023F4303999919-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--47FE48A07B1F404DBC023F4303999919-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--47FE48A07B1F404DBC023F4303999919-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--47FE48A07B1F404DBC023F4303999919-->  <VALUE><![CDATA[CPSamePassword]]></VALUE>
+<!--47FE48A07B1F404DBC023F4303999919-->  <MSGTEXT><![CDATA[Passwords must be the same]]></MSGTEXT>
+<!--47FE48A07B1F404DBC023F4303999919-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--47FE48A07B1F404DBC023F4303999919-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--47FE48A07B1F404DBC023F4303999919-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--47FE48A07B1F404DBC023F4303999919--></AD_MESSAGE>
+
 <!--4824BDCE0FDA46ADA4D79BA676791DFF--><AD_MESSAGE>
 <!--4824BDCE0FDA46ADA4D79BA676791DFF-->  <AD_MESSAGE_ID><![CDATA[4824BDCE0FDA46ADA4D79BA676791DFF]]></AD_MESSAGE_ID>
 <!--4824BDCE0FDA46ADA4D79BA676791DFF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -26498,6 +26510,18 @@
 <!--E652E8A6AC41454D817E71F6FEE67779-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--E652E8A6AC41454D817E71F6FEE67779--></AD_MESSAGE>
 
+<!--E665B521F8DE4D238ED4D2BD8764D609--><AD_MESSAGE>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <AD_MESSAGE_ID><![CDATA[E665B521F8DE4D238ED4D2BD8764D609]]></AD_MESSAGE_ID>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <VALUE><![CDATA[CPDifferentPasswordInFields]]></VALUE>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <MSGTEXT><![CDATA[The password must be the same in both fields]]></MSGTEXT>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--E665B521F8DE4D238ED4D2BD8764D609-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--E665B521F8DE4D238ED4D2BD8764D609--></AD_MESSAGE>
+
 <!--E667A3DF0E1D4FA6BFEE696F302C1663--><AD_MESSAGE>
 <!--E667A3DF0E1D4FA6BFEE696F302C1663-->  <AD_MESSAGE_ID><![CDATA[E667A3DF0E1D4FA6BFEE696F302C1663]]></AD_MESSAGE_ID>
 <!--E667A3DF0E1D4FA6BFEE696F302C1663-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/security/Login.html	Fri Feb 19 13:42:53 2016 +0100
+++ b/src/org/openbravo/erpCommon/security/Login.html	Mon Feb 22 11:31:04 2016 +0100
@@ -40,6 +40,8 @@
 <script language="JavaScript" type="text/javascript" id="recBrowserMsgText">var recBrowserMsgText = 'xx';</script>
 <script language="JavaScript" type="text/javascript" id="identificationFailureTitle">var identificationFailureTitle = 'xx';</script>
 <script language="JavaScript" type="text/javascript" id="errorEmptyContent">var errorEmptyContent = 'xx';</script>
+<script language="JavaScript" type="text/javascript" id="errorSamePassword">var errorSamePassword = 'xx';</script>
+<script language="JavaScript" type="text/javascript" id="errorDifferentPasswordInFields">var errorDifferentPasswordInFields = 'xx';</script>
 
 <script language="JavaScript" type="text/javascript">
 var validBrowserFirefox = '38.0.0.0';
@@ -187,8 +189,8 @@
 </script>
 <script type="text/javascript">
 function buttonOK_click() {
-    if (document.getElementById('resetPassword').value =='true' && document.getElementById('user').value !== document.getElementById('password').value){
-        setLoginMessage('Error', "Passwords must be the same", "The password must be the same in both fields");
+    if (document.getElementById('resetPassword').value ==='true' && document.getElementById('user').value !== document.getElementById('password').value){
+        setLoginMessage('Error', errorSamePassword, errorDifferentPasswordInFields);
         return true;
     }
     if (focusedWindowElement.id === 'user' && document.getElementById('user').value !== '' && document.getElementById('password').value === '') {
--- a/src/org/openbravo/erpCommon/security/Login.java	Fri Feb 19 13:42:53 2016 +0100
+++ b/src/org/openbravo/erpCommon/security/Login.java	Mon Feb 22 11:31:04 2016 +0100
@@ -86,11 +86,14 @@
             "IDENTIFICATION_FAILURE_TITLE", systemClient.getLanguage().getLanguage());
         final String emptyUsernameOrPasswordText = Utility.messageBD(this,
             "EMPTY_USERNAME_OR_PASSWORD_TEXT", systemClient.getLanguage().getLanguage());
-
+        final String errorSamePassword = Utility.messageBD(this, "CPSamePassword", systemClient
+            .getLanguage().getLanguage());
+        final String errorDifferentPasswordInFields = Utility.messageBD(this,
+            "CPDifferentPasswordInFields", systemClient.getLanguage().getLanguage());
         if (OBVersion.getInstance().is30()) {
           printPageLogin30(vars, response, strTheme, cacheMsg, validBrowserMsg, orHigherMsg,
               recBrowserMsgTitle, recBrowserMsgText, identificationFailureTitle,
-              emptyUsernameOrPasswordText);
+              emptyUsernameOrPasswordText, errorSamePassword, errorDifferentPasswordInFields);
         } else {
           printPageLogin250(response, strTheme, cacheMsg, validBrowserMsg, orHigherMsg);
         }
@@ -246,7 +249,8 @@
   private void printPageLogin30(VariablesSecureApp vars, HttpServletResponse response,
       String strTheme, String cacheMsg, String validBrowserMsg, String orHigherMsg,
       String recBrowserMsgTitle, String recBrowserMsgText, String identificationFailureTitle,
-      String emptyUsernameOrPasswordText) throws IOException, ServletException {
+      String emptyUsernameOrPasswordText, String errorSamePassword,
+      String errorDifferentPasswordInFields) throws IOException, ServletException {
 
     boolean showForgeLogo = true;
     boolean showITLogo = false;
@@ -324,6 +328,14 @@
     xmlDocument.setParameter("errorEmptyContent",
         emptyUserNameOrPasswordFinal.replaceAll("\\n", "\n"));
 
+    String errorSamePasswordFinal = "var errorSamePassword = \"" + errorSamePassword + "\"";
+    xmlDocument.setParameter("errorSamePassword", errorSamePasswordFinal.replaceAll("\\n", "\n"));
+
+    String errorDifferentPasswordInFieldsFinal = "var errorDifferentPasswordInFields = \""
+        + errorDifferentPasswordInFields + "\"";
+    xmlDocument.setParameter("errorDifferentPasswordInFields",
+        errorDifferentPasswordInFieldsFinal.replaceAll("\\n", "\n"));
+
     String validBrowserMsgFinal = "var validBrowserMsg = \"" + validBrowserMsg + "\"";
     String orHigherMsgFinal = "var validBrowserMsgOrHigher = \"" + orHigherMsg + "\"";
     xmlDocument.setParameter("validBrowserMsg", validBrowserMsgFinal.replaceAll("\\n", "\n"));
--- a/src/org/openbravo/erpCommon/security/Login.xml	Fri Feb 19 13:42:53 2016 +0100
+++ b/src/org/openbravo/erpCommon/security/Login.xml	Mon Feb 22 11:31:04 2016 +0100
@@ -34,5 +34,7 @@
   <PARAMETER id="errorMsgContent" name="errorMsgContent" default="" />
   <PARAMETER id="identificationFailureTitle" name="identificationFailureTitle" default="" />
   <PARAMETER id="errorEmptyContent" name="errorEmptyContent" default="" />
+  <PARAMETER id="errorSamePassword" name="errorSamePassword" default="" />
+  <PARAMETER id="errorDifferentPasswordInFields" name="errorDifferentPasswordInFields" default="" />
   <PARAMETER id="sign-in" name="sign-in" default=""/>
 </REPORT>