svn commit: r1429273 - /ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1429273 - /ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java

jleroux@apache.org
Author: jleroux
Date: Sat Jan  5 12:40:13 2013
New Revision: 1429273

URL: http://svn.apache.org/viewvc?rev=1429273&view=rev
Log:
A sightly modified patch from Raghavendra Prakash for "In version 10.04 - After clicking on lookup, display login page again" https://issues.apache.org/jira/browse/OFBIZ-4937

Step 1: Login - https://localhost:8443/catalog/control/main; Login with credentials
Step 2: Now, select Category lookup; Lookup popup appears; Just get rid of the popup
Step 3: Next, select 'Party' menu item from application tab; You will see the login page again.
Cause: externalKey becomes stale.

I have fixed the issue with a small work around:
externalLoginKeysWR - contains the userLogin for externalLoginKey from app-level tabs
Logic behind: The userlogin could not be found for the external key after the lookup request handled
by OFBiz. The external key with app level tabs become stale once the lookup request is handled, and userlogin
was removed for app level tabs' external keys. As a work around, this fastmap still maitains association with that
external key. When the userlogin could not be found with external key, it would be searched in this fastmap.
This is accomplished in checkExternalLoginKey and getExternalLoginKey methods

jleroux; After testing, I cleaned Raghavendra's contribution. It's maybe not the best way, but it works.

Modified:
    ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java

Modified: ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=1429273&r1=1429272&r2=1429273&view=diff
==============================================================================
--- ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original)
+++ ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Sat Jan  5 12:40:13 2013
@@ -84,6 +84,8 @@ public class LoginWorker {
 
     /** This Map is keyed by the randomly generated externalLoginKey and the value is a UserLogin GenericValue object */
     public static Map<String, GenericValue> externalLoginKeys = FastMap.newInstance();
+    // This fast map is added as work around for repeated login issue
+    public static Map<String, GenericValue> externalLoginKeysWR = FastMap.newInstance();
 
     public static StringWrapper makeLoginUrl(PageContext pageContext) {
         return makeLoginUrl(pageContext, "checkLogin");
@@ -130,6 +132,8 @@ public class LoginWorker {
             // if the session has a previous key in place, remove it from the master list
             String sesExtKey = (String) session.getAttribute(EXTERNAL_LOGIN_KEY_ATTR);
             if (sesExtKey != null) {
+                // Work around for repeated login issue
+                externalLoginKeysWR.put(sesExtKey, userLogin);
                 externalLoginKeys.remove(sesExtKey);
             }
 
@@ -152,6 +156,7 @@ public class LoginWorker {
         String sesExtKey = (String) session.getAttribute(EXTERNAL_LOGIN_KEY_ATTR);
         if (sesExtKey != null) {
             externalLoginKeys.remove(sesExtKey);
+            externalLoginKeysWR.remove(sesExtKey);
         }
     }
 
@@ -522,6 +527,7 @@ public class LoginWorker {
     public static void doBasicLogin(GenericValue userLogin, HttpServletRequest request) {
         HttpSession session = request.getSession();
         session.setAttribute("userLogin", userLogin);
+        request.setAttribute("userLogin", userLogin);
 
         String javaScriptEnabled = null;
         try {
@@ -925,6 +931,11 @@ public class LoginWorker {
         if (externalKey == null) return "success";
 
         GenericValue userLogin = (GenericValue) LoginWorker.externalLoginKeys.get(externalKey);
+        // Work around for repeated login issue
+        if (userLogin == null) {
+            userLogin = (GenericValue) LoginWorker.externalLoginKeysWR.get(externalKey);
+            externalLoginKeysWR.remove(externalKey);
+        }
         if (userLogin != null) {
             //to check it's the right tenant
             //in case username and password are the same in different tenants