Skip to content

Commit d8b097f

Browse files
committed
Replaced direct null checks on username, password, and token with UtilValidate.isEmpty() method calls for consistency.
1 parent c59336f commit d8b097f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ public static String checkLogin(HttpServletRequest request, HttpServletResponse
340340
if (token == null) token = (String) session.getAttribute("TOKEN");
341341

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

347347
// make sure this attribute is not in the request; this avoids infinite recursion when a login by less stringent criteria (like not checkout the hasLoggedOut field) passes; this is not a normal circumstance but can happen with custom code or in funny error situations when the userLogin service gets the userLogin object but runs into another problem and fails to return an error
@@ -419,9 +419,9 @@ public static String login(HttpServletRequest request, HttpServletResponse respo
419419
}
420420
}
421421

422-
if (username == null) username = (String) session.getAttribute("USERNAME");
423-
if (password == null) password = (String) session.getAttribute("PASSWORD");
424-
if (token == null) token = (String) session.getAttribute("TOKEN");
422+
if (UtilValidate.isEmpty(username)) username = (String) session.getAttribute("USERNAME");
423+
if (UtilValidate.isEmpty(password)) password = (String) session.getAttribute("PASSWORD");
424+
if (UtilValidate.isEmpty(token)) token = (String) session.getAttribute("TOKEN");
425425

426426
// 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...
427427
if (UtilValidate.isNotEmpty(request.getAttribute("USERNAME"))) {

0 commit comments

Comments
 (0)