fixes bug 39885: link to a document isn't followed properly after login
authorCarlos Aristu <carlos.aristu@openbravo.com>
Mon, 14 Jan 2019 10:37:29 +0100
changeset 35310 0c885bc2fcec
parent 35309 9a417375877c
child 35311 76e291866ae6
fixes bug 39885: link to a document isn't followed properly after login

Before[1] the URL query string used to specify the link to a concrete document was being stored in session. After that changeset the code to save that value in session was no longer being executed, so it was not possible to recover the document link information.

To solve this problem now we keep the query string with the link information in the URL, and we retrieve it from there when needed.


[1] https://code.openbravo.com/erp/devel/pi/rev/6d6a3a710fd21bbc60de46c5778b212c64ec300c
src/index.jsp
src/org/openbravo/base/secureApp/LoginHandler.java
src/org/openbravo/erpCommon/security/Login.html
web/js/login.js
web/js/utils.js
--- a/src/index.jsp	Fri Jan 11 09:54:50 2019 +0100
+++ b/src/index.jsp	Mon Jan 14 10:37:29 2019 +0100
@@ -32,7 +32,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2011-2018 Openbravo SLU
+ * All portions are Copyright (C) 2011-2019 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -45,7 +45,11 @@
 
 AuthenticationManager authManager = AuthenticationManager.getAuthenticationManager(this);
 if (!adSessionPresent && !authManager.useExternalLoginPage()) {
-  response.sendRedirect(authManager.getLoginURL(request));
+  if (request.getQueryString() != null) {
+    response.sendRedirect(authManager.getLoginURL(request) + "?" + request.getQueryString());
+  } else {
+    response.sendRedirect(authManager.getLoginURL(request));
+  }
   return;
 }
 
--- a/src/org/openbravo/base/secureApp/LoginHandler.java	Fri Jan 11 09:54:50 2019 +0100
+++ b/src/org/openbravo/base/secureApp/LoginHandler.java	Mon Jan 14 10:37:29 2019 +0100
@@ -1,7 +1,6 @@
 /*
  ************************************************************************************
-
- * Copyright (C) 2001-2018 Openbravo S.L.U.
+ * Copyright (C) 2001-2019 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -401,7 +400,7 @@
       }
 
       String target = getUserStartPage(strUserAuth, userLoginDefaults,
-          vars.getSessionValue("target"), vars.getSessionValue("targetQueryString"));
+          vars.getSessionValue("target"), vars.getStringParameter("targetQueryString"));
       vars.removeSessionValue("target");
 
       goToTarget(res, target);
--- a/src/org/openbravo/erpCommon/security/Login.html	Fri Jan 11 09:54:50 2019 +0100
+++ b/src/org/openbravo/erpCommon/security/Login.html	Mon Jan 14 10:37:29 2019 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2010-2018 Openbravo SLU 
+ * All portions are Copyright (C) 2010-2019 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -55,7 +55,7 @@
 var recBrowserSafari = '12.0.0.0';
 
 // currentRevision must be the same value as the one returned by getCurrentRevision() (see utils.js)
-var currentRevision = '33640';
+var currentRevision = '35310';
 
 beforeLoadDo();
 </script>
--- a/web/js/login.js	Fri Jan 11 09:54:50 2019 +0100
+++ b/web/js/login.js	Mon Jan 14 10:37:29 2019 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2017-2018 Openbravo SLU 
+ * All portions are Copyright (C) 2017-2019 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -70,6 +70,7 @@
 }
 
 function doLogin(command) {
+  var extraParams;
   if (document.getElementById('resetPassword').value === 'true' && document.getElementById('user').value !== document.getElementById('password').value) {
     setLoginMessage('Error', errorSamePassword, errorDifferentPasswordInFields);
     return true;
@@ -91,12 +92,17 @@
     }
     disableButton('buttonOK');
     command = command || (document.getElementById('resetPassword').value === 'true' ? 'FORCE_RESET_PASSWORD' : 'DEFAULT');
-    submitXmlHttpRequest(loginResult, document.frmIdentificacion, command, '../secureApp/LoginHandler.html', false, null, null);
+    extraParams = '&targetQueryString=' + getURLQueryString();
+    submitXmlHttpRequest(loginResult, document.frmIdentificacion, command, '../secureApp/LoginHandler.html', false, extraParams, null);
   }
 
   return false;
 }
 
+function getURLQueryString() {
+  return encodeURIComponent(window.location.search.substr(1));
+}
+
 function loginResult(paramXMLParticular, XMLHttpRequestObj) {
   var strText = '';
   if (getReadyStateHandler(XMLHttpRequestObj, null, false)) {
@@ -513,10 +519,6 @@
  */
 
 function submitXmlHttpRequest(callbackFunction, formObject, Command, Action, debug, extraParams, paramXMLReq) {
-  submitXmlHttpRequestWithParams(callbackFunction, formObject, Command, Action, debug, null, paramXMLReq);
-}
-
-function submitXmlHttpRequestWithParams(callbackFunction, formObject, Command, Action, debug, extraParams, paramXMLReq) {
   var XMLHttpRequestObj = null;
   XMLHttpRequestObj = getXMLHttpRequest();
   if (formObject === null) {
--- a/web/js/utils.js	Fri Jan 11 09:54:50 2019 +0100
+++ b/web/js/utils.js	Mon Jan 14 10:37:29 2019 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2018 Openbravo SLU
+ * All portions are Copyright (C) 2001-2019 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -105,7 +105,7 @@
 * Return a number that would be checked at the Login screen to know if the file is cached with the correct version
 */
 function getCurrentRevision() {
-  var number = '33640';
+  var number = '35310';
   return number;
 }