From 2f6e6a3123648d6cd2754a0f7cf1a047e98f2f6b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 4 May 2021 23:30:21 +0200 Subject: [PATCH] core: improve messaging when flow manager denied request Signed-off-by: Jens Langhammer --- authentik/core/sources/flow_manager.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/authentik/core/sources/flow_manager.py b/authentik/core/sources/flow_manager.py index 6d650ec77..177c2ca16 100644 --- a/authentik/core/sources/flow_manager.py +++ b/authentik/core/sources/flow_manager.py @@ -148,22 +148,24 @@ class SourceFlowManager: def get_flow(self, **kwargs) -> HttpResponse: """Get the flow response based on user_matching_mode""" action, connection = self.get_action() - if not connection: - return redirect("/") - if action == Action.LINK: - self._logger.debug("Linking existing user") - return self.handle_existing_user_link(connection) - if action == Action.AUTH: - self._logger.debug("Handling auth user") - return self.handle_auth_user(connection) - if action == Action.ENROLL: - self._logger.debug("Handling enrollment of new user") - return self.handle_enroll(connection) + if connection: + if action == Action.LINK: + self._logger.debug("Linking existing user") + return self.handle_existing_user_link(connection) + if action == Action.AUTH: + self._logger.debug("Handling auth user") + return self.handle_auth_user(connection) + if action == Action.ENROLL: + self._logger.debug("Handling enrollment of new user") + return self.handle_enroll(connection) # Default case, assume deny messages.error( self.request, _( - "Request to authenticate with %(source)s has been denied!" + ( + "Request to authenticate with %(source)s has been denied. Please authenticate " + "with the source you've previously signed up with." + ) % {"source": self.source.name} ), )