From 319564077694342383bbca09ab2fe34ba64e3954 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 20 Sep 2021 19:26:25 +0200 Subject: [PATCH] stages/email: slugify token identifier Signed-off-by: Jens Langhammer --- authentik/stages/email/stage.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/authentik/stages/email/stage.py b/authentik/stages/email/stage.py index a97d56e8c..123b1fc15 100644 --- a/authentik/stages/email/stage.py +++ b/authentik/stages/email/stage.py @@ -5,6 +5,7 @@ from django.contrib import messages from django.http import HttpRequest, HttpResponse from django.urls import reverse from django.utils.http import urlencode +from django.utils.text import slugify from django.utils.timezone import now from django.utils.translation import gettext as _ from rest_framework.fields import CharField @@ -64,7 +65,7 @@ class EmailStageView(ChallengeStageView): ) # + 1 because django timesince always rounds down token_filters = { "user": pending_user, - "identifier": f"ak-email-stage-{current_stage.name}-{pending_user}", + "identifier": slugify(f"ak-email-stage-{current_stage.name}-{pending_user}"), } # Don't check for validity here, we only care if the token exists tokens = Token.objects.filter(**token_filters) @@ -120,7 +121,7 @@ class EmailStageView(ChallengeStageView): challenge = EmailChallenge( data={ "type": ChallengeTypes.NATIVE.value, - "title": "Email sent.", + "title": _("Email sent."), } ) return challenge