Extract errorMessage from generateLoginPageHtml
This commit is contained in:
parent
ae23e3f5f4
commit
28d353d731
|
@ -189,15 +189,7 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
|||
}
|
||||
|
||||
private String generateLoginPageHtml(HttpServletRequest request, boolean loginError, boolean logoutSuccess) {
|
||||
String errorMsg = "Invalid credentials";
|
||||
if (loginError) {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session != null) {
|
||||
AuthenticationException ex = (AuthenticationException) session
|
||||
.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
|
||||
errorMsg = (ex != null) ? ex.getMessage() : "Invalid credentials";
|
||||
}
|
||||
}
|
||||
String errorMsg = loginError ? getLoginErrorMessage(request) : "Invalid credentials";
|
||||
String contextPath = request.getContextPath();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<!DOCTYPE html>\n");
|
||||
|
@ -272,6 +264,15 @@ public class DefaultLoginPageGeneratingFilter extends GenericFilterBean {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getLoginErrorMessage(HttpServletRequest request) {
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session != null &&
|
||||
session.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION) instanceof AuthenticationException exception) {
|
||||
return exception.getMessage();
|
||||
}
|
||||
return "Invalid credentials";
|
||||
}
|
||||
|
||||
private String renderHiddenInputs(HttpServletRequest request) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, String> input : this.resolveHiddenInputs.apply(request).entrySet()) {
|
||||
|
|
Loading…
Reference in New Issue