Display general error message when WebFlux oauth2Login() fails

Issue gh-5562 gh-6484
This commit is contained in:
Joe Grandja 2019-12-05 16:54:31 -05:00
parent c40a17b4d1
commit 4d9cee116c
1 changed files with 4 additions and 2 deletions

View File

@ -106,7 +106,7 @@ public class LoginPageGeneratingWebFilter implements WebFilter {
+ " <body>\n"
+ " <div class=\"container\">\n"
+ formLogin(queryParams, csrfTokenHtmlInput)
+ oauth2LoginLinks(contextPath, this.oauth2AuthenticationUrlToClientName)
+ oauth2LoginLinks(queryParams, contextPath, this.oauth2AuthenticationUrlToClientName)
+ " </div>\n"
+ " </body>\n"
+ "</html>";
@ -135,12 +135,14 @@ public class LoginPageGeneratingWebFilter implements WebFilter {
+ " </form>\n";
}
private static String oauth2LoginLinks(String contextPath, Map<String, String> oauth2AuthenticationUrlToClientName) {
private static String oauth2LoginLinks(MultiValueMap<String, String> queryParams, String contextPath, Map<String, String> oauth2AuthenticationUrlToClientName) {
if (oauth2AuthenticationUrlToClientName.isEmpty()) {
return "";
}
boolean isError = queryParams.containsKey("error");
StringBuilder sb = new StringBuilder();
sb.append("<div class=\"container\"><h2 class=\"form-signin-heading\">Login with OAuth 2.0</h2>");
sb.append(createError(isError));
sb.append("<table class=\"table table-striped\">\n");
for (Map.Entry<String, String> clientAuthenticationUrlToClientName : oauth2AuthenticationUrlToClientName.entrySet()) {
sb.append(" <tr><td>");