stages/identification: set primary_action based on flow designation

closes #3589

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-09-14 10:14:13 +02:00
parent dc622a836f
commit 6b8b596c92
3 changed files with 31 additions and 20 deletions

View File

@ -58,7 +58,7 @@ class AuthenticatorValidateStageTests(FlowTestCase):
flow, flow,
component="ak-stage-identification", component="ak-stage-identification",
password_fields=False, password_fields=False,
primary_action="Log in", primary_action="Continue",
user_fields=["username"], user_fields=["username"],
sources=[], sources=[],
show_source_labels=False, show_source_labels=False,

View File

@ -21,6 +21,7 @@ from authentik.flows.challenge import (
ChallengeTypes, ChallengeTypes,
RedirectChallenge, RedirectChallenge,
) )
from authentik.flows.models import FlowDesignation
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER
from authentik.flows.stage import PLAN_CONTEXT_PENDING_USER_IDENTIFIER, ChallengeStageView from authentik.flows.stage import PLAN_CONTEXT_PENDING_USER_IDENTIFIER, ChallengeStageView
from authentik.flows.views.executor import SESSION_KEY_APPLICATION_PRE, SESSION_KEY_GET from authentik.flows.views.executor import SESSION_KEY_APPLICATION_PRE, SESSION_KEY_GET
@ -165,12 +166,18 @@ class IdentificationStageView(ChallengeStageView):
return user return user
return None return None
def get_primary_action(self) -> str:
"""Get the primary action label for this stage"""
if self.executor.flow.designation == FlowDesignation.AUTHENTICATION:
return _("Log in")
return _("Continue")
def get_challenge(self) -> Challenge: def get_challenge(self) -> Challenge:
current_stage: IdentificationStage = self.executor.current_stage current_stage: IdentificationStage = self.executor.current_stage
challenge = IdentificationChallenge( challenge = IdentificationChallenge(
data={ data={
"type": ChallengeTypes.NATIVE.value, "type": ChallengeTypes.NATIVE.value,
"primary_action": _("Log in"), "primary_action": self.get_primary_action(),
"component": "ak-stage-identification", "component": "ak-stage-identification",
"user_fields": current_stage.user_fields, "user_fields": current_stage.user_fields,
"password_fields": bool(current_stage.password_stage), "password_fields": bool(current_stage.password_stage),

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-09-06 16:46+0000\n" "POT-Creation-Date: 2022-09-14 08:12+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: authentik/admin/api/tasks.py:99 #: authentik/admin/api/tasks.py:115
#, python-format #, python-format
msgid "Successfully re-scheduled Task %(name)s!" msgid "Successfully re-scheduled Task %(name)s!"
msgstr "" msgstr ""
@ -48,7 +48,7 @@ msgstr ""
msgid "authentik Export - %(date)s" msgid "authentik Export - %(date)s"
msgstr "" msgstr ""
#: authentik/blueprints/v1/tasks.py:104 authentik/crypto/tasks.py:93 #: authentik/blueprints/v1/tasks.py:106 authentik/crypto/tasks.py:93
#, python-format #, python-format
msgid "Successfully imported %(count)d files." msgid "Successfully imported %(count)d files."
msgstr "" msgstr ""
@ -246,25 +246,25 @@ msgstr ""
msgid "You're about to sign into %(application)s." msgid "You're about to sign into %(application)s."
msgstr "" msgstr ""
#: authentik/crypto/api.py:143 #: authentik/crypto/api.py:144
msgid "Subject-alt name" msgid "Subject-alt name"
msgstr "" msgstr ""
#: authentik/crypto/models.py:35 #: authentik/crypto/models.py:30
msgid "PEM-encoded Certificate data" msgid "PEM-encoded Certificate data"
msgstr "" msgstr ""
#: authentik/crypto/models.py:38 #: authentik/crypto/models.py:33
msgid "" msgid ""
"Optional Private Key. If this is set, you can use this keypair for " "Optional Private Key. If this is set, you can use this keypair for "
"encryption." "encryption."
msgstr "" msgstr ""
#: authentik/crypto/models.py:107 #: authentik/crypto/models.py:102
msgid "Certificate-Key Pair" msgid "Certificate-Key Pair"
msgstr "" msgstr ""
#: authentik/crypto/models.py:108 #: authentik/crypto/models.py:103
msgid "Certificate-Key Pairs" msgid "Certificate-Key Pairs"
msgstr "" msgstr ""
@ -859,20 +859,20 @@ msgstr ""
msgid "Redirecting to %(app)s..." msgid "Redirecting to %(app)s..."
msgstr "" msgstr ""
#: authentik/providers/oauth2/views/userinfo.py:41 #: authentik/providers/oauth2/views/userinfo.py:46
#: authentik/providers/oauth2/views/userinfo.py:42 #: authentik/providers/oauth2/views/userinfo.py:47
msgid "GitHub Compatibility: Access your User Information" msgid "GitHub Compatibility: Access your User Information"
msgstr "" msgstr ""
#: authentik/providers/oauth2/views/userinfo.py:43 #: authentik/providers/oauth2/views/userinfo.py:48
msgid "GitHub Compatibility: Access you Email addresses" msgid "GitHub Compatibility: Access you Email addresses"
msgstr "" msgstr ""
#: authentik/providers/oauth2/views/userinfo.py:44 #: authentik/providers/oauth2/views/userinfo.py:49
msgid "GitHub Compatibility: Access your Groups" msgid "GitHub Compatibility: Access your Groups"
msgstr "" msgstr ""
#: authentik/providers/oauth2/views/userinfo.py:45 #: authentik/providers/oauth2/views/userinfo.py:50
msgid "authentik API Access on behalf of your user" msgid "authentik API Access on behalf of your user"
msgstr "" msgstr ""
@ -1401,7 +1401,7 @@ msgstr ""
msgid "TOTP Authenticator Setup Stages" msgid "TOTP Authenticator Setup Stages"
msgstr "" msgstr ""
#: authentik/stages/authenticator_validate/challenge.py:115 #: authentik/stages/authenticator_validate/challenge.py:117
msgid "Invalid Token" msgid "Invalid Token"
msgstr "" msgstr ""
@ -1647,10 +1647,14 @@ msgstr ""
msgid "Identification Stages" msgid "Identification Stages"
msgstr "" msgstr ""
#: authentik/stages/identification/stage.py:173 #: authentik/stages/identification/stage.py:172
msgid "Log in" msgid "Log in"
msgstr "" msgstr ""
#: authentik/stages/identification/stage.py:173
msgid "Continue"
msgstr ""
#: authentik/stages/invitation/models.py:47 #: authentik/stages/invitation/models.py:47
msgid "Invitation Stage" msgid "Invitation Stage"
msgstr "" msgstr ""
@ -1823,16 +1827,16 @@ msgstr ""
msgid "No Pending data." msgid "No Pending data."
msgstr "" msgstr ""
#: authentik/tenants/models.py:20 #: authentik/tenants/models.py:23
msgid "" msgid ""
"Domain that activates this tenant. Can be a superset, i.e. `a.b` for `aa.b` " "Domain that activates this tenant. Can be a superset, i.e. `a.b` for `aa.b` "
"and `ba.b`" "and `ba.b`"
msgstr "" msgstr ""
#: authentik/tenants/models.py:87 #: authentik/tenants/models.py:95
msgid "Tenant" msgid "Tenant"
msgstr "" msgstr ""
#: authentik/tenants/models.py:88 #: authentik/tenants/models.py:96
msgid "Tenants" msgid "Tenants"
msgstr "" msgstr ""