Skip to content

Commit

Permalink
Replaced direct null checks on username, password, and token with Uti…
Browse files Browse the repository at this point in the history
…lValidate.isEmpty() method calls for consistency.
  • Loading branch information
dixitdeepak committed Dec 14, 2023
1 parent 565d8a3 commit 47e7959
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -338,8 +338,8 @@ public static String checkLogin(HttpServletRequest request, HttpServletResponse
if (token == null) token = (String) session.getAttribute("TOKEN");

// in this condition log them in if not already; if not logged in or can't log in, save parameters and return error
if (username == null
|| (password == null && token == null)
if (UtilValidate.isEmpty(username)
|| (UtilValidate.isEmpty(password) && UtilValidate.isEmpty(token))
|| "error".equals(login(request, response))) {

// make sure this attribute is not in the request; this avoids infinite recursion when a login by less stringent criteria
Expand Down Expand Up @@ -417,9 +417,9 @@ public static String login(HttpServletRequest request, HttpServletResponse respo
}
}

if (username == null) username = (String) session.getAttribute("USERNAME");
if (password == null) password = (String) session.getAttribute("PASSWORD");
if (token == null) token = (String) session.getAttribute("TOKEN");
if (UtilValidate.isEmpty(username)) username = (String) session.getAttribute("USERNAME");
if (UtilValidate.isEmpty(password)) password = (String) session.getAttribute("PASSWORD");
if (UtilValidate.isEmpty(token)) token = (String) session.getAttribute("TOKEN");

// allow a username and/or password in a request attribute to override the request parameter or the session attribute;
// this way a preprocessor can play with these a bit...
Expand Down

0 comments on commit 47e7959

Please sign in to comment.