From b1715c37252bf82759f2621423fa7be7a6705984 Mon Sep 17 00:00:00 2001 From: vrockai Date: Thu, 3 Oct 2013 17:44:05 +0200 Subject: [PATCH] KEYCLOAK-83 add error page --- .../org/keycloak/service/FormServiceImpl.java | 15 +++--- .../resources/forms/theme/default/error.ftl | 4 +- .../theme/default/template-login-action.ftl | 4 +- .../services/resources/SocialResource.java | 20 +++---- .../services/resources/flows/Flows.java | 4 -- .../services/resources/flows/FormFlows.java | 4 ++ .../services/resources/flows/OAuthFlows.java | 2 +- .../services/resources/flows/PageFlows.java | 52 ------------------- .../services/resources/flows/Pages.java | 2 +- 9 files changed, 30 insertions(+), 77 deletions(-) delete mode 100755 services/src/main/java/org/keycloak/services/resources/flows/PageFlows.java diff --git a/forms/src/main/java/org/keycloak/service/FormServiceImpl.java b/forms/src/main/java/org/keycloak/service/FormServiceImpl.java index 7efa87dab3..3dedc5e0d8 100644 --- a/forms/src/main/java/org/keycloak/service/FormServiceImpl.java +++ b/forms/src/main/java/org/keycloak/service/FormServiceImpl.java @@ -65,12 +65,12 @@ public class FormServiceImpl implements FormService { commandMap.put(Pages.LOGIN_RESET_PASSWORD, new CommandPassword()); commandMap.put(Pages.LOGIN_UPDATE_PASSWORD, new CommandPassword()); commandMap.put(Pages.ACCESS, new CommandAccess()); - commandMap.put(Pages.SECURITY_FAILURE, new CommandSecurityFailure()); commandMap.put(Pages.SOCIAL, new CommandSocial()); commandMap.put(Pages.TOTP, new CommandTotp()); commandMap.put(Pages.LOGIN_CONFIG_TOTP, new CommandTotp()); commandMap.put(Pages.LOGIN_TOTP, new CommandLoginTotp()); commandMap.put(Pages.LOGIN_VERIFY_EMAIL, new CommandLoginTotp()); + commandMap.put(Pages.ERROR, new CommandError()); } public String getId(){ @@ -143,11 +143,6 @@ public class FormServiceImpl implements FormService { } } - private class CommandSecurityFailure implements Command { - public void exec(Map attributes, FormServiceDataBean dataBean) { - } - } - private class CommandPassword implements Command { public void exec(Map attributes, FormServiceDataBean dataBean) { if (dataBean.getError() != null){ @@ -253,6 +248,14 @@ public class FormServiceImpl implements FormService { } } + private class CommandError implements Command { + public void exec(Map attributes, FormServiceDataBean dataBean) { + if (dataBean.getError() != null){ + attributes.put("error", new ErrorBean(dataBean.getError())); + } + } + } + private interface Command { public void exec(Map attributes, FormServiceDataBean dataBean); } diff --git a/forms/src/main/resources/META-INF/resources/forms/theme/default/error.ftl b/forms/src/main/resources/META-INF/resources/forms/theme/default/error.ftl index a7f1f5be91..64ca460b7a 100755 --- a/forms/src/main/resources/META-INF/resources/forms/theme/default/error.ftl +++ b/forms/src/main/resources/META-INF/resources/forms/theme/default/error.ftl @@ -1,6 +1,6 @@ <#-- TODO: Only a placeholder, implementation needed --> <#import "template-login-action.ftl" as layout> -<@layout.registrationLayout bodyClass="reset"; section> +<@layout.registrationLayout bodyClass="reset" isErrorPage=true; section> <#if section = "title"> We're sorry... @@ -12,7 +12,7 @@ <#elseif section = "form">

Something happened and we could not process your request.

-

Please make sure the URL you entered is correct.

+

${error.summary}

Go to the homepage ยป <#elseif section = "info" > diff --git a/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login-action.ftl b/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login-action.ftl index 70794b16cd..c2920cf57f 100644 --- a/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login-action.ftl +++ b/forms/src/main/resources/META-INF/resources/forms/theme/default/template-login-action.ftl @@ -1,4 +1,4 @@ -<#macro registrationLayout bodyClass> +<#macro registrationLayout bodyClass isErrorPage=false> @@ -37,7 +37,7 @@ <#nested "form"> - <#if error?has_content> + <#if !isErrorPage && error?has_content>