stages/invitation: fix incorrect pk check for invitation's flow

closes #4278

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-12-27 13:55:51 +01:00
parent 4a6f8d2ef2
commit 20a4dfd13d
No known key found for this signature in database
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@ from typing import Optional
from deepmerge import always_merger from deepmerge import always_merger
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext_lazy as _
from authentik.flows.stage import StageView from authentik.flows.stage import StageView
from authentik.flows.views.executor import SESSION_KEY_GET from authentik.flows.views.executor import SESSION_KEY_GET
@ -44,7 +45,7 @@ class InvitationStageView(StageView):
if not invite: if not invite:
self.logger.debug("invalid invitation", token=token) self.logger.debug("invalid invitation", token=token)
return None return None
if invite.flow and invite.flow.pk != self.executor.plan.flow_pk: if invite.flow and invite.flow.pk.hex != self.executor.plan.flow_pk:
self.logger.debug("invite for incorrect flow", expected=invite.flow.slug) self.logger.debug("invite for incorrect flow", expected=invite.flow.slug)
return None return None
return invite return invite
@ -57,7 +58,7 @@ class InvitationStageView(StageView):
if not invite: if not invite:
if stage.continue_flow_without_invitation: if stage.continue_flow_without_invitation:
return self.executor.stage_ok() return self.executor.stage_ok()
return self.executor.stage_invalid() return self.executor.stage_invalid(_("Invalid invite/invite not found"))
self.executor.plan.context[INVITATION_IN_EFFECT] = True self.executor.plan.context[INVITATION_IN_EFFECT] = True
self.executor.plan.context[INVITATION] = invite self.executor.plan.context[INVITATION] = invite

View File

@ -77,7 +77,7 @@ attributes: !If [
Conditionally add YAML to a blueprint. Conditionally add YAML to a blueprint.
Similar to a one-line if, the first argument is the condition, which can be any valid yaml or custom tag. It will be evaluted as boolean in python. However, keep in mind that dictionaries and lists will always evaluate to `true`, unless they are empty. Similar to a one-line if, the first argument is the condition, which can be any valid yaml or custom tag. It will be evaluated as boolean in python. However, keep in mind that dictionaries and lists will always evaluate to `true`, unless they are empty.
The second argument is used when the condition is `true`, and the third - when `false`. The YAML inside both arguments will be fully resolved, thus it is possible to use custom YAML tags and even nest them inside dictionaries and lists. The second argument is used when the condition is `true`, and the third - when `false`. The YAML inside both arguments will be fully resolved, thus it is possible to use custom YAML tags and even nest them inside dictionaries and lists.