Fixed issue 39776: Exception appears after login with user with no roles
authorJavier Armendáriz <javier.armendariz@openbravo.com>
Fri, 14 Dec 2018 12:21:18 +0100
changeset 32603 ac63e7aee561
parent 32602 553e257f85e8
child 32604 fc8dbbcb6d2d
Fixed issue 39776: Exception appears after login with user with no roles

Now current session is cleared if a error is found in login process. This
prevents the user to be stuck in a exception screen with no chance to log in
again.
src/org/openbravo/base/secureApp/LoginHandler.java
--- a/src/org/openbravo/base/secureApp/LoginHandler.java	Mon Jul 31 09:00:49 2017 +0200
+++ b/src/org/openbravo/base/secureApp/LoginHandler.java	Fri Dec 14 12:21:18 2018 +0100
@@ -479,9 +479,10 @@
       // 3.0 instances show the message in the same 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", "Error".equals(msgType) ? null : action);
+        jsonMsg.put("target", loginHasError ? null : action);
         jsonMsg.put("messageType", msgType);
         jsonMsg.put("messageTitle", title);
         jsonMsg.put("messageText", msg);
@@ -489,6 +490,11 @@
         if ("Confirmation".equals(msgType)) {
           jsonMsg.put("command", "FORCE_NAMED_USER");
         }
+
+        if (loginHasError) {
+          vars.clearSession(false);
+        }
+
         response.setContentType("application/json;charset=UTF-8");
         final PrintWriter out = response.getWriter();
         out.print(jsonMsg.toString());