You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/01/08 12:05:22 UTC
svn commit: r1430208 - in /ofbiz/branches/release10.04: ./
framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
Author: jleroux
Date: Tue Jan 8 11:05:21 2013
New Revision: 1430208
URL: http://svn.apache.org/viewvc?rev=1430208&view=rev
Log:
"Applied fix from trunk for revision: 1068283"
------------------------------------------------------------------------
r1068283 | jleroux | 2011-02-08 08:47:25 +0100 (mar., 08 févr. 2011) | 8 lines
Fix "Ajax requests prevent externalLoginKey parameters from working correctly" (https://issues.apache.org/jira/browse/OFBIZ-3862) - OFBIZ-3862
Scott reported: To clarify, the problem only occurs if the Ajax call results in a screen being rendered since it is the ScreenRenderer that causes a new key to be generated.
Bilgin suggested: I think a solution would be to skip generating of new external login key for Ajax requests.
Ajax requests can be identified by presence of 'X-Requested-With': 'XMLHttpRequest', http header. It is set by most of the Javascript libraries we use: prototype, jquery.
I coded it
------------------------------------------------------------------------
Modified:
ofbiz/branches/release10.04/ (props changed)
ofbiz/branches/release10.04/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
Propchange: ofbiz/branches/release10.04/
------------------------------------------------------------------------------
Merged /ofbiz/trunk:r1068283
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=1430208&r1=1430207&r2=1430208&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 Tue Jan 8 11:05:21 2013
@@ -129,7 +129,10 @@ public class LoginWorker {
synchronized (session) {
// 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) {
+ if (isAjax(request)) return sesExtKey;
+
externalLoginKeys.remove(sesExtKey);
}
@@ -1023,4 +1026,9 @@ public class LoginWorker {
}
return userLoginSessionMap;
}
+
+ public static boolean isAjax(HttpServletRequest request) {
+ return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
+ }
+
}