fixed bug 25466: login performance when checking user lock
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 27 Jan 2014 15:32:04 +0100
changeset 21875 496cbeb8f989
parent 21874 d7ed2de7ac4a
child 21876 9b47b9cdf8c1
fixed bug 25466: login performance when checking user lock

username is not joined but passed as parameter, in this way query is
executed in a more efficient manner
src/org/openbravo/base/secureApp/UserLock.java
--- a/src/org/openbravo/base/secureApp/UserLock.java	Fri Jan 24 20:55:49 2014 +0530
+++ b/src/org/openbravo/base/secureApp/UserLock.java	Mon Jan 27 15:32:04 2014 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2010-2012 Openbravo SL 
+ * All portions are Copyright (C) 2010-2014 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -117,12 +117,16 @@
     hql.append("   and s.username = :name");
     hql.append("   and s.creationDate > (select coalesce(max(s1.creationDate), s.creationDate-1)");
     hql.append("                           from ADSession s1");
-    hql.append("                          where s1.username = s.username");
+    hql.append("                          where s1.username = :name");
     hql.append("                            and s1.loginStatus!='F')");
     Query q = OBDal.getInstance().getSession().createQuery(hql.toString());
     q.setParameter("name", userName);
 
+    long t = System.currentTimeMillis();
     numberOfFails = ((Long) q.list().get(0)).intValue();
+    log4j.debug("Time taken to check user lock " + (System.currentTimeMillis() - t)
+        + "ms. Number of failed login attempts: " + numberOfFails);
+
     if (numberOfFails == 0) {
       delay = 0;
       return;