stages/invitation: handle incorrectly formatted token

closes #4481

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-01-22 00:03:39 +01:00
parent 767ffc09d0
commit b288393cd4
No known key found for this signature in database

View file

@ -2,6 +2,7 @@
from typing import Optional from typing import Optional
from deepmerge import always_merger from deepmerge import always_merger
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -41,7 +42,11 @@ class InvitationStageView(StageView):
token = self.get_token() token = self.get_token()
if not token: if not token:
return None return None
try:
invite: Invitation = Invitation.objects.filter(pk=token).first() invite: Invitation = Invitation.objects.filter(pk=token).first()
except ValidationError:
self.logger.debug("invalid invitation", token=token)
return None
if not invite: if not invite:
self.logger.debug("invalid invitation", token=token) self.logger.debug("invalid invitation", token=token)
return None return None