From f51515f3de50b3e4f3643466b6fcb36154ba10e6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 3 Nov 2021 00:07:13 +0100 Subject: [PATCH] stages/invitation: don't throw 404 error in stage Signed-off-by: Jens Langhammer --- authentik/stages/invitation/stage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/authentik/stages/invitation/stage.py b/authentik/stages/invitation/stage.py index f65301fba..d8d24315b 100644 --- a/authentik/stages/invitation/stage.py +++ b/authentik/stages/invitation/stage.py @@ -50,7 +50,12 @@ class InvitationStageView(StageView): return self.executor.stage_ok() return self.executor.stage_invalid() - invite: Invitation = get_object_or_404(Invitation, pk=token) + invite: Invitation = Invitation.objects.filter(pk=token).first() + if not invite: + LOGGER.debug("invalid invitation", token=token) + if stage.continue_flow_without_invitation: + return self.executor.stage_ok() + return self.executor.stage_invalid() self.executor.plan.context[INVITATION_IN_EFFECT] = True self.executor.plan.context[INVITATION] = invite