[ChangePassword] Added messages in AD. Solved some problems with OBDAL default restrictions
authorJonathan Bueno <jonathan.bueno@openbravo.com>
Wed, 16 Dec 2015 10:11:33 +0100
changeset 28644 6bce485227be
parent 28643 ac519ab9312a
child 28645 ff8998e5a827
[ChangePassword] Added messages in AD. Solved some problems with OBDAL default restrictions
src-db/database/sourcedata/AD_MESSAGE.xml
src/org/openbravo/base/secureApp/LoginHandler.java
src/org/openbravo/base/secureApp/LoginUtils.java
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Thu Dec 10 12:16:57 2015 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Dec 16 10:11:33 2015 +0100
@@ -20494,6 +20494,18 @@
 <!--66BEE4A0FBD44C96B2967716918A1318-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--66BEE4A0FBD44C96B2967716918A1318--></AD_MESSAGE>
 
+<!--66C9D1145558443EA2B6038CA2201049--><AD_MESSAGE>
+<!--66C9D1145558443EA2B6038CA2201049-->  <AD_MESSAGE_ID><![CDATA[66C9D1145558443EA2B6038CA2201049]]></AD_MESSAGE_ID>
+<!--66C9D1145558443EA2B6038CA2201049-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--66C9D1145558443EA2B6038CA2201049-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--66C9D1145558443EA2B6038CA2201049-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--66C9D1145558443EA2B6038CA2201049-->  <VALUE><![CDATA[CPUpdatePassword]]></VALUE>
+<!--66C9D1145558443EA2B6038CA2201049-->  <MSGTEXT><![CDATA[Write a new password]]></MSGTEXT>
+<!--66C9D1145558443EA2B6038CA2201049-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--66C9D1145558443EA2B6038CA2201049-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--66C9D1145558443EA2B6038CA2201049-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--66C9D1145558443EA2B6038CA2201049--></AD_MESSAGE>
+
 <!--67178C115E364ED2B68EC84473CD7404--><AD_MESSAGE>
 <!--67178C115E364ED2B68EC84473CD7404-->  <AD_MESSAGE_ID><![CDATA[67178C115E364ED2B68EC84473CD7404]]></AD_MESSAGE_ID>
 <!--67178C115E364ED2B68EC84473CD7404-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -21903,6 +21915,18 @@
 <!--87F4030110BF457ABC427FEA68750143-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--87F4030110BF457ABC427FEA68750143--></AD_MESSAGE>
 
+<!--883A1F99972748F19C4E901C76589770--><AD_MESSAGE>
+<!--883A1F99972748F19C4E901C76589770-->  <AD_MESSAGE_ID><![CDATA[883A1F99972748F19C4E901C76589770]]></AD_MESSAGE_ID>
+<!--883A1F99972748F19C4E901C76589770-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--883A1F99972748F19C4E901C76589770-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--883A1F99972748F19C4E901C76589770-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--883A1F99972748F19C4E901C76589770-->  <VALUE><![CDATA[CPExpiryPassword]]></VALUE>
+<!--883A1F99972748F19C4E901C76589770-->  <MSGTEXT><![CDATA[Your password has expired. Please provide a new one.]]></MSGTEXT>
+<!--883A1F99972748F19C4E901C76589770-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--883A1F99972748F19C4E901C76589770-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--883A1F99972748F19C4E901C76589770-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--883A1F99972748F19C4E901C76589770--></AD_MESSAGE>
+
 <!--88A1D0A0F67F49339B2639EA4E5F6B4B--><AD_MESSAGE>
 <!--88A1D0A0F67F49339B2639EA4E5F6B4B-->  <AD_MESSAGE_ID><![CDATA[88A1D0A0F67F49339B2639EA4E5F6B4B]]></AD_MESSAGE_ID>
 <!--88A1D0A0F67F49339B2639EA4E5F6B4B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -25220,6 +25244,18 @@
 <!--D3696EC5C14B4068B5E2331A89CD1A2A-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--D3696EC5C14B4068B5E2331A89CD1A2A--></AD_MESSAGE>
 
+<!--D3A7922C8400453CABDBE823D90C0623--><AD_MESSAGE>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <AD_MESSAGE_ID><![CDATA[D3A7922C8400453CABDBE823D90C0623]]></AD_MESSAGE_ID>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <VALUE><![CDATA[CPDifferentPassword]]></VALUE>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <MSGTEXT><![CDATA[Password must be different from the previous one]]></MSGTEXT>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--D3A7922C8400453CABDBE823D90C0623-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--D3A7922C8400453CABDBE823D90C0623--></AD_MESSAGE>
+
 <!--D3A9E2D613734D5E847C11DF4DDAC958--><AD_MESSAGE>
 <!--D3A9E2D613734D5E847C11DF4DDAC958-->  <AD_MESSAGE_ID><![CDATA[D3A9E2D613734D5E847C11DF4DDAC958]]></AD_MESSAGE_ID>
 <!--D3A9E2D613734D5E847C11DF4DDAC958-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/base/secureApp/LoginHandler.java	Thu Dec 10 12:16:57 2015 +0100
+++ b/src/org/openbravo/base/secureApp/LoginHandler.java	Wed Dec 16 10:11:33 2015 +0100
@@ -102,9 +102,11 @@
         try {
           if (sameOldPassword) {
             OBError errorMsg = new OBError();
+            String msg = Utility.messageBD(myPool, "CPUpdatePassword", vars.getLanguage());
+            String title = Utility.messageBD(myPool, "CPDifferentPassword", vars.getLanguage());
             errorMsg.setType("Error");
-            errorMsg.setTitle("Password must be different from the previous one");
-            errorMsg.setMessage("Write a new password");
+            errorMsg.setTitle(title);
+            errorMsg.setMessage(msg);
             throw new AuthenticationExpiryPasswordException("Same password than old one", errorMsg);
           }
           AuthenticationManager authManager = AuthenticationManager.getAuthenticationManager(this);
@@ -138,13 +140,17 @@
           final OBError errorMsg = aepe.getOBError();
           if (errorMsg != null) {
             vars.removeSessionValue("#LoginErrorMsg");
+
             if (errorMsg.getMessage().equalsIgnoreCase("Write a new password")) {
-              goToUpdatePassword(res, vars, "Write a new password",
-                  "Password must be different from the previous one", "Error",
-                  "../security/Login_FS.html", doRedirect);
+              String msg = Utility.messageBD(myPool, "CPUpdatePassword", vars.getLanguage());
+              String title = Utility.messageBD(myPool, "CPDifferentPassword", vars.getLanguage());
+              goToUpdatePassword(res, vars, msg, title, "Error", "../security/Login_FS.html",
+                  doRedirect);
             } else {
-              goToUpdatePassword(res, vars, "Update your password", "Password is expired", "Error",
-                  "../security/Login_FS.html", doRedirect);
+              String msg = Utility.messageBD(myPool, "CPUpdatePassword", vars.getLanguage());
+              String title = Utility.messageBD(myPool, "CPExpiryPassword", vars.getLanguage());
+              goToUpdatePassword(res, vars, msg, title, "Error", "../security/Login_FS.html",
+                  doRedirect);
             }
           }
         }
--- a/src/org/openbravo/base/secureApp/LoginUtils.java	Thu Dec 10 12:16:57 2015 +0100
+++ b/src/org/openbravo/base/secureApp/LoginUtils.java	Wed Dec 16 10:11:33 2015 +0100
@@ -109,7 +109,7 @@
 
       final OBCriteria<User> obc = OBDal.getInstance().createCriteria(User.class);
       obc.add(Restrictions.like("username", login));
-
+      obc.setFilterOnReadableClients(false);
       final List<User> listUser = obc.list();
       User userOB = listUser.get(0);
       Date lastUpdateDate = userOB.getUpdatePasswordDate();
@@ -141,7 +141,7 @@
 
       final OBCriteria<User> obc = OBDal.getInstance().createCriteria(User.class);
       obc.add(Restrictions.like("username", login));
-
+      obc.setFilterOnReadableClients(false);
       final List<User> listUser = obc.list();
       User userOB = listUser.get(0);
       String oldPassword = userOB.getPassword();
@@ -173,6 +173,7 @@
       final OBCriteria<User> obc = OBDal.getInstance().createCriteria(User.class);
       obc.add(Restrictions.like("username", login));
       obc.add(Restrictions.like("password", hashedPassword));
+      obc.setFilterOnReadableClients(false);
       final List<User> listUser = obc.list();
       String userId = "-1";