From 17653e7e74989b76eecfdffc23fe63a424ded2ec Mon Sep 17 00:00:00 2001 From: pedroigor Date: Thu, 26 Feb 2015 15:27:10 -0300 Subject: [PATCH] [KEYCLOAK-883] - Reverting change that redirects to error page when federating identities.. --- .../resources/IdentityBrokerService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java b/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java index b2a11bb1d6..5f9501ecc3 100644 --- a/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java +++ b/services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java @@ -323,7 +323,7 @@ public class IdentityBrokerService { federatedUser.addRequiredAction(UPDATE_PROFILE); } } catch (Exception e) { - return redirectToErrorPage(e.getMessage(), e); + return redirectToLoginPage(e, clientCode); } } @@ -447,6 +447,20 @@ public class IdentityBrokerService { return Flows.forwardToSecurityFailurePage(this.session, this.realmModel, this.uriInfo, message); } + private Response redirectToLoginPage(Throwable t, ClientSessionCode clientCode) { + String message = t.getMessage(); + + if (message == null) { + message = "Unexpected error when authenticating with identity provider"; + } + + fireErrorEvent(message); + return Flows.forms(this.session, this.realmModel, clientCode.getClientSession().getClient(), this.uriInfo) + .setClientSessionCode(clientCode.getCode()) + .setError(message) + .createLogin(); + } + private Response badRequest(String message) { fireErrorEvent(message); return Flows.errors().error(message, Status.BAD_REQUEST);