enterprise/stages/source: fix error when creating source stage from blueprint (#9810)
* enterprise/stages/source: fix error when creating source stage from blueprint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix error for pretend user Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix unrelated frontend bug Signed-off-by: Jens Langhammer <jens@goauthentik.io> * cleanup Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -18,9 +18,12 @@ class SourceStageSerializer(EnterpriseRequiredMixin, StageSerializer):
|
|||||||
source = Source.objects.filter(pk=_source.pk).select_subclasses().first()
|
source = Source.objects.filter(pk=_source.pk).select_subclasses().first()
|
||||||
if not source:
|
if not source:
|
||||||
raise ValidationError("Invalid source")
|
raise ValidationError("Invalid source")
|
||||||
login_button = source.ui_login_button(self.context["request"])
|
if "request" in self.context:
|
||||||
if not login_button:
|
login_button = source.ui_login_button(self.context["request"])
|
||||||
raise ValidationError("Invalid source selected, only web-based sources are supported.")
|
if not login_button:
|
||||||
|
raise ValidationError(
|
||||||
|
"Invalid source selected, only web-based sources are supported."
|
||||||
|
)
|
||||||
return source
|
return source
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -54,7 +54,7 @@ class SourceStageView(ChallengeStageView):
|
|||||||
def create_flow_token(self) -> FlowToken:
|
def create_flow_token(self) -> FlowToken:
|
||||||
"""Save the current flow state in a token that can be used to resume this flow"""
|
"""Save the current flow state in a token that can be used to resume this flow"""
|
||||||
pending_user: User = self.get_pending_user()
|
pending_user: User = self.get_pending_user()
|
||||||
if pending_user.is_anonymous:
|
if pending_user.is_anonymous or not pending_user.pk:
|
||||||
pending_user = get_anonymous_user()
|
pending_user = get_anonymous_user()
|
||||||
current_stage: SourceStage = self.executor.current_stage
|
current_stage: SourceStage = self.executor.current_stage
|
||||||
identifier = slugify(f"ak-source-stage-{current_stage.name}-{str(uuid4())}")
|
identifier = slugify(f"ak-source-stage-{current_stage.name}-{str(uuid4())}")
|
||||||
|
@ -304,6 +304,5 @@ class TestAuthenticatorWebAuthnStage(FlowTestCase):
|
|||||||
SERVER_PORT="9000",
|
SERVER_PORT="9000",
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
print(response.content)
|
|
||||||
self.assertStageRedirects(response, reverse("authentik_core:root-redirect"))
|
self.assertStageRedirects(response, reverse("authentik_core:root-redirect"))
|
||||||
self.assertTrue(WebAuthnDevice.objects.filter(user=self.user).exists())
|
self.assertTrue(WebAuthnDevice.objects.filter(user=self.user).exists())
|
||||||
|
@ -49,7 +49,7 @@ export class FlowErrorStage extends BaseStage<FlowErrorChallenge, FlowChallengeR
|
|||||||
<ak-empty-state
|
<ak-empty-state
|
||||||
icon="fa-times"
|
icon="fa-times"
|
||||||
header=${this.challenge.error
|
header=${this.challenge.error
|
||||||
? html`${this.challenge.error}`
|
? this.challenge.error
|
||||||
: msg("Something went wrong! Please try again later.")}
|
: msg("Something went wrong! Please try again later.")}
|
||||||
>
|
>
|
||||||
<div slot="body">
|
<div slot="body">
|
||||||
|
Reference in New Issue
Block a user