core: improve messaging when flow manager denied request

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-04 23:30:21 +02:00
parent 36b674349a
commit 2f6e6a3123
1 changed files with 14 additions and 12 deletions

View File

@ -148,22 +148,24 @@ class SourceFlowManager:
def get_flow(self, **kwargs) -> HttpResponse: def get_flow(self, **kwargs) -> HttpResponse:
"""Get the flow response based on user_matching_mode""" """Get the flow response based on user_matching_mode"""
action, connection = self.get_action() action, connection = self.get_action()
if not connection: if connection:
return redirect("/") if action == Action.LINK:
if action == Action.LINK: self._logger.debug("Linking existing user")
self._logger.debug("Linking existing user") return self.handle_existing_user_link(connection)
return self.handle_existing_user_link(connection) if action == Action.AUTH:
if action == Action.AUTH: self._logger.debug("Handling auth user")
self._logger.debug("Handling auth user") return self.handle_auth_user(connection)
return self.handle_auth_user(connection) if action == Action.ENROLL:
if action == Action.ENROLL: self._logger.debug("Handling enrollment of new user")
self._logger.debug("Handling enrollment of new user") return self.handle_enroll(connection)
return self.handle_enroll(connection)
# Default case, assume deny # Default case, assume deny
messages.error( messages.error(
self.request, 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} % {"source": self.source.name}
), ),
) )