Direct link url now passes through login
authorMartin Taal <martin.taal@openbravo.com>
Wed, 09 Mar 2011 12:05:01 +0100
changeset 11137 1097ad23966d
parent 11136 ebf9e80e7ce4
child 11138 2a2c6483ec7d
Direct link url now passes through login
src-core/src/org/openbravo/base/VariablesBase.java
src/org/openbravo/authentication/basic/DefaultAuthenticationManager.java
src/org/openbravo/erpCommon/security/Menu.java
--- a/src-core/src/org/openbravo/base/VariablesBase.java	Wed Mar 09 12:04:25 2011 +0100
+++ b/src-core/src/org/openbravo/base/VariablesBase.java	Wed Mar 09 12:05:01 2011 +0100
@@ -1410,6 +1410,7 @@
     if (log4j.isDebugEnabled())
       log4j.debug("...: removing session");
     String target = "";
+    String targetQueryString = null;
     try {
       String sessionName;
       Enumeration<?> e = session.getAttributeNames();
@@ -1417,16 +1418,24 @@
         sessionName = (String) e.nextElement();
         if (log4j.isDebugEnabled())
           log4j.debug("  session name: " + sessionName);
-        if (!all && sessionName.equalsIgnoreCase("target"))
+        if (!all && sessionName.equalsIgnoreCase("target")) {
           target = (String) session.getAttribute(sessionName);
+        }
+        if (!all && sessionName.equalsIgnoreCase("targetQueryString")) {
+          targetQueryString = (String) session.getAttribute(sessionName);
+        }
         session.removeAttribute(sessionName);
         e = session.getAttributeNames();
       }
     } catch (Exception e) {
       log4j.error("clearSession error " + e);
     }
-    if (!target.equals(""))
+    if (!target.equals("")) {
       session.setAttribute("TARGET", target);
+    }
+    if (targetQueryString != null) {
+      session.setAttribute("TARGETQUERYSTRING", targetQueryString);
+    }
   }
 
   /**
--- a/src/org/openbravo/authentication/basic/DefaultAuthenticationManager.java	Wed Mar 09 12:04:25 2011 +0100
+++ b/src/org/openbravo/authentication/basic/DefaultAuthenticationManager.java	Wed Mar 09 12:05:01 2011 +0100
@@ -86,6 +86,9 @@
       // Storing target string to redirect after a successful login
       variables.setSessionValue("target", strDireccionLocal + "/security/Menu.html"
           + (qString != null && !qString.equals("") ? "?" + qString : ""));
+      if (qString != null && !qString.equals("")) {
+        variables.setSessionValue("targetQueryString", qString);
+      }
 
       if (strAjax != null && !strAjax.equals(""))
         bdErrorAjax(response, "Error", "", Utility.messageBD(this.conn, "NotLogged", variables
--- a/src/org/openbravo/erpCommon/security/Menu.java	Wed Mar 09 12:04:25 2011 +0100
+++ b/src/org/openbravo/erpCommon/security/Menu.java	Wed Mar 09 12:05:01 2011 +0100
@@ -71,7 +71,14 @@
             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")) {
-          response.sendRedirect(".." + startPage);
+          final String storedQueryString = vars.getSessionValue("targetQueryString");
+          if (storedQueryString != null && storedQueryString.length() > 0) {
+            final String separator = startPage.contains("?") ? "&" : "?";
+            response.sendRedirect(".." + startPage + separator + storedQueryString);
+          } else {
+            response.sendRedirect(".." + startPage);
+          }
+          vars.removeSessionValue("target");
           return;
         }
       } catch (PropertyConflictException e) {