[ChangePassword] Fixed some minor issues. Messages added. Refactor of some files
authorJonathan Bueno <jonathan.bueno@openbravo.com>
Wed, 23 Dec 2015 10:52:18 +0100
changeset 28651 a8105d7b8e40
parent 28650 be05b136c217
child 28652 26d23375a92b
[ChangePassword] Fixed some minor issues. Messages added. Refactor of some files
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src/org/openbravo/base/secureApp/LoginHandler.java
src/org/openbravo/base/secureApp/LoginUtils.java
src/org/openbravo/erpCommon/security/Login.html
--- a/src-db/database/sourcedata/AD_FIELD.xml	Mon Dec 21 16:26:08 2015 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Wed Dec 23 10:52:18 2015 +0100
@@ -50310,7 +50310,7 @@
 <!--3813-->  <DISPLAYLOGIC><![CDATA[@SMTPHost@!null & @SMTPHost@!'']]></DISPLAYLOGIC>
 <!--3813-->  <DISPLAYLENGTH><![CDATA[20]]></DISPLAYLENGTH>
 <!--3813-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--3813-->  <SEQNO><![CDATA[80]]></SEQNO>
+<!--3813-->  <SEQNO><![CDATA[90]]></SEQNO>
 <!--3813-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--3813-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--3813-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -62524,7 +62524,7 @@
 <!--5161-->  <DISPLAYLOGIC><![CDATA[@SMTPHost@!null & @SMTPHost@!'']]></DISPLAYLOGIC>
 <!--5161-->  <DISPLAYLENGTH><![CDATA[20]]></DISPLAYLENGTH>
 <!--5161-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--5161-->  <SEQNO><![CDATA[100]]></SEQNO>
+<!--5161-->  <SEQNO><![CDATA[110]]></SEQNO>
 <!--5161-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--5161-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--5161-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -62555,7 +62555,7 @@
 <!--5162-->  <DISPLAYLOGIC><![CDATA[@SMTPHost@!null & @SMTPHost@!'']]></DISPLAYLOGIC>
 <!--5162-->  <DISPLAYLENGTH><![CDATA[20]]></DISPLAYLENGTH>
 <!--5162-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--5162-->  <SEQNO><![CDATA[110]]></SEQNO>
+<!--5162-->  <SEQNO><![CDATA[120]]></SEQNO>
 <!--5162-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--5162-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--5162-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -62586,7 +62586,7 @@
 <!--5163-->  <DISPLAYLOGIC><![CDATA[@SMTPHost@!null & @SMTPHost@!'']]></DISPLAYLOGIC>
 <!--5163-->  <DISPLAYLENGTH><![CDATA[20]]></DISPLAYLENGTH>
 <!--5163-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--5163-->  <SEQNO><![CDATA[120]]></SEQNO>
+<!--5163-->  <SEQNO><![CDATA[130]]></SEQNO>
 <!--5163-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--5163-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--5163-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -62617,7 +62617,7 @@
 <!--5164-->  <DISPLAYLOGIC><![CDATA[@SMTPHost@!null & @SMTPHost@!'']]></DISPLAYLOGIC>
 <!--5164-->  <DISPLAYLENGTH><![CDATA[20]]></DISPLAYLENGTH>
 <!--5164-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--5164-->  <SEQNO><![CDATA[130]]></SEQNO>
+<!--5164-->  <SEQNO><![CDATA[140]]></SEQNO>
 <!--5164-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--5164-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--5164-->  <ISENCRYPTED><![CDATA[Y]]></ISENCRYPTED>
@@ -73489,7 +73489,7 @@
 <!--5887-->  <DISPLAYLOGIC><![CDATA[@SMTPHost@!null & @SMTPHost@!'']]></DISPLAYLOGIC>
 <!--5887-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--5887-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--5887-->  <SEQNO><![CDATA[90]]></SEQNO>
+<!--5887-->  <SEQNO><![CDATA[100]]></SEQNO>
 <!--5887-->  <ISSAMELINE><![CDATA[Y]]></ISSAMELINE>
 <!--5887-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--5887-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -183872,7 +183872,7 @@
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--10DB133E8FDE4DD98E298833940D8DE7-->  <NAME><![CDATA[Days to password expiration]]></NAME>
+<!--10DB133E8FDE4DD98E298833940D8DE7-->  <NAME><![CDATA[Days to Password Expiration]]></NAME>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <DESCRIPTION><![CDATA[Define the days that user password must be valid from previous password change]]></DESCRIPTION>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <HELP><![CDATA[Define the days that user password must be valid from previous password change, if value is set to 0 no update will be required, for value greater than 0, password must be updated when the last password update date of the user plus the days defined here achieves.]]></HELP>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
@@ -183882,7 +183882,7 @@
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--10DB133E8FDE4DD98E298833940D8DE7-->  <SEQNO><![CDATA[430]]></SEQNO>
+<!--10DB133E8FDE4DD98E298833940D8DE7-->  <SEQNO><![CDATA[80]]></SEQNO>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--10DB133E8FDE4DD98E298833940D8DE7-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -191223,7 +191223,7 @@
 <!--21D7540351B54FCAB5FC1866330454EB-->  <DISPLAYLOGIC><![CDATA[@Org_Acctdim_Isenable@='Y' & @Acctdim_Centrally_Maintained@='Y']]></DISPLAYLOGIC>
 <!--21D7540351B54FCAB5FC1866330454EB-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--21D7540351B54FCAB5FC1866330454EB-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--21D7540351B54FCAB5FC1866330454EB-->  <SEQNO><![CDATA[170]]></SEQNO>
+<!--21D7540351B54FCAB5FC1866330454EB-->  <SEQNO><![CDATA[180]]></SEQNO>
 <!--21D7540351B54FCAB5FC1866330454EB-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--21D7540351B54FCAB5FC1866330454EB-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--21D7540351B54FCAB5FC1866330454EB-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -200373,7 +200373,7 @@
 <!--393F614AD39F4BB4B0287B53A6D14C7E-->  <DISPLAYLOGIC><![CDATA[@Acctdim_Centrally_Maintained@='Y']]></DISPLAYLOGIC>
 <!--393F614AD39F4BB4B0287B53A6D14C7E-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--393F614AD39F4BB4B0287B53A6D14C7E-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
-<!--393F614AD39F4BB4B0287B53A6D14C7E-->  <SEQNO><![CDATA[150]]></SEQNO>
+<!--393F614AD39F4BB4B0287B53A6D14C7E-->  <SEQNO><![CDATA[160]]></SEQNO>
 <!--393F614AD39F4BB4B0287B53A6D14C7E-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--393F614AD39F4BB4B0287B53A6D14C7E-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--393F614AD39F4BB4B0287B53A6D14C7E-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -204952,7 +204952,7 @@
 <!--44FA9B5980474579845B7A0175DE24C7-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--44FA9B5980474579845B7A0175DE24C7-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--44FA9B5980474579845B7A0175DE24C7-->  <DISPLAYLENGTH><![CDATA[19]]></DISPLAYLENGTH>
-<!--44FA9B5980474579845B7A0175DE24C7-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--44FA9B5980474579845B7A0175DE24C7-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
 <!--44FA9B5980474579845B7A0175DE24C7-->  <SEQNO><![CDATA[300]]></SEQNO>
 <!--44FA9B5980474579845B7A0175DE24C7-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--44FA9B5980474579845B7A0175DE24C7-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
@@ -237213,7 +237213,7 @@
 <!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
 <!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <SEQNO><![CDATA[140]]></SEQNO>
+<!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <SEQNO><![CDATA[150]]></SEQNO>
 <!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--7D8571DE9B4B47CB88F9DB275422AEFD-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
@@ -289254,7 +289254,7 @@
 <!--D22CED5BEC9940AD99657C22CD2CCC08-->  <DISPLAYLOGIC><![CDATA[@Org_Acctdim_Isenable@='Y' & @Acctdim_Centrally_Maintained@='Y']]></DISPLAYLOGIC>
 <!--D22CED5BEC9940AD99657C22CD2CCC08-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
 <!--D22CED5BEC9940AD99657C22CD2CCC08-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
-<!--D22CED5BEC9940AD99657C22CD2CCC08-->  <SEQNO><![CDATA[160]]></SEQNO>
+<!--D22CED5BEC9940AD99657C22CD2CCC08-->  <SEQNO><![CDATA[170]]></SEQNO>
 <!--D22CED5BEC9940AD99657C22CD2CCC08-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
 <!--D22CED5BEC9940AD99657C22CD2CCC08-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
 <!--D22CED5BEC9940AD99657C22CD2CCC08-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Mon Dec 21 16:26:08 2015 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Dec 23 10:52:18 2015 +0100
@@ -19141,6 +19141,18 @@
 <!--47409688AF1E4A698F396E8FFCF01CBE-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--47409688AF1E4A698F396E8FFCF01CBE--></AD_MESSAGE>
 
+<!--477D32C1DD00461BB399A6D6E0DFB479--><AD_MESSAGE>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <AD_MESSAGE_ID><![CDATA[477D32C1DD00461BB399A6D6E0DFB479]]></AD_MESSAGE_ID>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <VALUE><![CDATA[CPSamePasswordThanOld]]></VALUE>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <MSGTEXT><![CDATA[Same password than old one]]></MSGTEXT>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--477D32C1DD00461BB399A6D6E0DFB479-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--477D32C1DD00461BB399A6D6E0DFB479--></AD_MESSAGE>
+
 <!--478F1A67DE4D4CEABA652C04A7D50B63--><AD_MESSAGE>
 <!--478F1A67DE4D4CEABA652C04A7D50B63-->  <AD_MESSAGE_ID><![CDATA[478F1A67DE4D4CEABA652C04A7D50B63]]></AD_MESSAGE_ID>
 <!--478F1A67DE4D4CEABA652C04A7D50B63-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/base/secureApp/LoginHandler.java	Mon Dec 21 16:26:08 2015 +0100
+++ b/src/org/openbravo/base/secureApp/LoginHandler.java	Wed Dec 23 10:52:18 2015 +0100
@@ -107,7 +107,8 @@
             errorMsg.setType("Error");
             errorMsg.setTitle(title);
             errorMsg.setMessage(msg);
-            throw new AuthenticationExpiryPasswordException("Same password than old one", errorMsg);
+            throw new AuthenticationExpiryPasswordException(Utility.messageBD(myPool,
+                "CPSamePasswordThanOld", vars.getLanguage()), errorMsg);
           }
           AuthenticationManager authManager = AuthenticationManager.getAuthenticationManager(this);
 
--- a/src/org/openbravo/base/secureApp/LoginUtils.java	Mon Dec 21 16:26:08 2015 +0100
+++ b/src/org/openbravo/base/secureApp/LoginUtils.java	Wed Dec 23 10:52:18 2015 +0100
@@ -95,6 +95,20 @@
     }
   }
 
+  /**
+   * Returns the last update password date from login and unHashedPassword parameters
+   * 
+   * 
+   * 
+   * @param connectionProvider
+   *          , see the {@link DalConnectionProvider} for an instance of a ConnectionProvider for
+   *          the DAL.
+   * @param login
+   *          the login
+   * @param unHashedPassword
+   *          the password, the unhashed password as it is entered by the user.
+   * @return the last password update date from the user
+   */
   public static Date getUpdatePasswordDate(ConnectionProvider connectionProvider, String login,
       String unHashedPassword) {
     // Gets the expiry password date
@@ -129,6 +143,18 @@
 
   }
 
+  /**
+   * Returns a boolean indicating if password has been changed for user. The password must be
+   * different from previous one, otherwise method will return false
+   * 
+   * 
+   * 
+   * @param login
+   *          the login
+   * @param unHashedPassword
+   *          the password, the unhashed password as it is entered by the user.
+   * @return true in case that password has changed succesfully, false in other case
+   */
   public static Boolean updatePassword(String login, String unHashedPassword) {
     // Set the Updated password date
     try {
--- a/src/org/openbravo/erpCommon/security/Login.html	Mon Dec 21 16:26:08 2015 +0100
+++ b/src/org/openbravo/erpCommon/security/Login.html	Wed Dec 23 10:52:18 2015 +0100
@@ -206,7 +206,6 @@
           setLoginMessage('Error', identificationFailureTitle, errorEmptyContent);
         return true;
       }   
-
       disableButton('buttonOK');
       submitXmlHttpRequest(loginResult, document.frmIdentificacion, 'DEFAULT', '../secureApp/LoginHandler.html', false, null, null);
     }
@@ -236,13 +235,12 @@
       }
     }
     if (result.resetPassword && document.getElementById('loggedUser').value===''){
-        document.getElementById('loggedUser').value=result.loggedUser;
-        document.getElementById('resetPassword').value=result.resetPassword;
-        document.getElementById('user').value = '';
-        document.getElementById('user').type = 'password';
-        document.getElementById('userlabel').innerHTML = 'New Password';
-        document.getElementById('passwordlabel').innerHTML = 'Confirm Password';
-        setWindowElementFocus('user');
+      document.getElementById('loggedUser').value=result.loggedUser;
+      document.getElementById('resetPassword').value=result.resetPassword;
+      document.getElementById('user').value = '';
+      document.getElementById('user').type = 'password';
+      document.getElementById('userlabel').innerHTML = 'New Password';
+      document.getElementById('passwordlabel').innerHTML = 'Confirm Password';
     }
     if (shouldContinue) {
       try {
@@ -256,6 +254,9 @@
       }
       command = result.command || 'DEFAULT';
       submitCommandForm(command, false, null, result.target, target, true);
+    }else if (result.resetPassword){
+      enableButton('buttonOK');
+      setWindowElementFocus('user', 'id');
     } else {
       enableButton('buttonOK');
       setWindowElementFocus('password', 'id');