related to issue 39885: make it work also when redirecting to Menu.html
authorCarlos Aristu <carlos.aristu@openbravo.com>
Mon, 14 Jan 2019 13:23:02 +0100
changeset 35311 76e291866ae6
parent 35310 0c885bc2fcec
child 35312 5aff6a4a578c
related to issue 39885: make it work also when redirecting to Menu.html

This flow happens when some kind of license restriction is detected during the login process
src/org/openbravo/base/secureApp/LoginHandler.java
src/org/openbravo/erpCommon/security/Menu.java
--- a/src/org/openbravo/base/secureApp/LoginHandler.java	Mon Jan 14 10:37:29 2019 +0100
+++ b/src/org/openbravo/base/secureApp/LoginHandler.java	Mon Jan 14 13:23:02 2019 +0100
@@ -510,13 +510,16 @@
       ServletException {
     String msg = (message != null && !message.equals("")) ? message : Utility.messageBD(myPool,
         "CPEmptyUserPassword", vars.getLanguage());
+    String targetQueryString = vars.getStringParameter("targetQueryString");
+    String target = StringUtils.isBlank(targetQueryString) ? action : action + "?"
+        + targetQueryString;
 
     // Show the message in the login window, return a JSON object with the info to print the message
     try {
       boolean loginHasError = "Error".equals(msgType);
       JSONObject jsonMsg = new JSONObject();
       jsonMsg.put("showMessage", true);
-      jsonMsg.put("target", loginHasError ? null : action);
+      jsonMsg.put("target", loginHasError ? null : target);
       jsonMsg.put("messageType", msgType);
       jsonMsg.put("messageTitle", title);
       jsonMsg.put("messageText", msg);
--- a/src/org/openbravo/erpCommon/security/Menu.java	Mon Jan 14 10:37:29 2019 +0100
+++ b/src/org/openbravo/erpCommon/security/Menu.java	Mon Jan 14 13:23:02 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-2017 Openbravo SLU
+ * All portions are Copyright (C) 2001-2019 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -77,10 +77,9 @@
             OBContext.getOBContext().getUser(), OBContext.getOBContext().getRole(), null);
         // redirect if the startpage is there and if it is not the same as the standard
         if (startPage != null && !startPage.endsWith("/security/Menu.html")) {
-          final String storedQueryString = vars.getSessionValue("targetQueryString");
-          if (storedQueryString != null && storedQueryString.length() > 0) {
+          if (queryString != null && queryString.length() > 0) {
             final String separator = startPage.contains("?") ? "&" : "?";
-            response.sendRedirect(".." + startPage + separator + storedQueryString);
+            response.sendRedirect(".." + startPage + separator + queryString);
           } else {
             response.sendRedirect(".." + startPage);
           }