From f47ce9a3605f03290cd0e1f17c3f401a198e04f9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 12 Dec 2022 16:34:16 +0000 Subject: [PATCH] stages/user_login: prevent double success message when logging in via source Signed-off-by: Jens Langhammer --- authentik/stages/user_login/stage.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/authentik/stages/user_login/stage.py b/authentik/stages/user_login/stage.py index f243d5b59..ec26c2de3 100644 --- a/authentik/stages/user_login/stage.py +++ b/authentik/stages/user_login/stage.py @@ -5,7 +5,7 @@ from django.http import HttpRequest, HttpResponse from django.utils.translation import gettext as _ from authentik.core.models import User -from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER +from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, PLAN_CONTEXT_SOURCE from authentik.flows.stage import StageView from authentik.lib.utils.time import timedelta_from_string from authentik.stages.password import BACKEND_INBUILT @@ -52,5 +52,8 @@ class UserLoginStageView(StageView): session_duration=self.executor.current_stage.session_duration, ) self.request.session[USER_LOGIN_AUTHENTICATED] = True - messages.success(self.request, _("Successfully logged in!")) + # Only show success message if we don't have a source in the flow + # as sources show their own success messages + if not self.executor.plan.context.get(PLAN_CONTEXT_SOURCE, None): + messages.success(self.request, _("Successfully logged in!")) return self.executor.stage_ok()