svn commit: r454438 - in /incubator/ofbiz/trunk/framework: common/src/org/ofbiz/common/login/LoginServices.java 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: r454438 - in /incubator/ofbiz/trunk/framework: common/src/org/ofbiz/common/login/LoginServices.java webapp/src/org/ofbiz/webapp/control/LoginWorker.java

jonesde
Author: jonesde
Date: Mon Oct  9 10:42:40 2006
New Revision: 454438

URL: http://svn.apache.org/viewvc?view=rev&rev=454438
Log:
A couple of improvements to login error handling based on some funny issues found by a client using an older revision of OFBiz, but even though this code has been refactored a bit these problems still persisted in the latest code; this will better handle error with successful authentication, but failures in saving/resetting UserLogin and UserLoginHistory data

Modified:
    incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java
    incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java

Modified: incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java?view=diff&rev=454438&r1=454437&r2=454438
==============================================================================
--- incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java (original)
+++ incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/login/LoginServices.java Mon Oct  9 10:42:40 2006
@@ -277,12 +277,21 @@
                                     }
                                 }
                             } catch (GenericEntityException e) {
+                                String geeErrMsg = "Error saving UserLoginHistory";
+                                if (doStore) {
+                                    geeErrMsg += " and updating login status to reset hasLoggedOut, unsuccessful login count, etc.";
+                                }
+                                geeErrMsg += ": " + e.toString();
                                 try {
-                                    TransactionUtil.rollback(beganTransaction, "Error saving UserLoginHistory", e);
+                                    TransactionUtil.rollback(beganTransaction, geeErrMsg, e);
                                 } catch (GenericTransactionException e2) {
                                     Debug.logError(e2, "Could not rollback nested transaction: " + e2.getMessage(), module);
                                 }
                                 
+                                // if doStore is true then this error should not be ignored and we shouldn't consider it a successful login if this happens as there is something very wrong lower down that will bite us again later
+                                if (doStore) {
+                                    return ServiceUtil.returnError(geeErrMsg);
+                                }
                             } finally {
                                 try {
                                     TransactionUtil.commit(beganTransaction);

Modified: incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?view=diff&rev=454438&r1=454437&r2=454438
==============================================================================
--- incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original)
+++ incubator/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Mon Oct  9 10:42:40 2006
@@ -235,6 +235,9 @@
                 Debug.logInfo("reqParams Map: " + reqParams, module);
                 Debug.logInfo("queryString: " + queryString, module);
 
+                // make sure this attribute is not in the request; this avoids infinite recursion when a login by less stringent criteria (like not checkout the hasLoggedOut field) passes; this is not a normal circumstance but can happen with custom code or in funny error situations when the userLogin service gets the userLogin object but runs into another problem and fails to return an error
+                request.removeAttribute("_LOGIN_PASSED_");
+
                 session.setAttribute("_PREVIOUS_REQUEST_", request.getPathInfo());
                 if (queryString != null && queryString.length() > 0) {
                     session.setAttribute("_PREVIOUS_PARAMS_", queryString);