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()
|
||||
if not source:
|
||||
raise ValidationError("Invalid source")
|
||||
if "request" in self.context:
|
||||
login_button = source.ui_login_button(self.context["request"])
|
||||
if not login_button:
|
||||
raise ValidationError("Invalid source selected, only web-based sources are supported.")
|
||||
raise ValidationError(
|
||||
"Invalid source selected, only web-based sources are supported."
|
||||
)
|
||||
return source
|
||||
|
||||
class Meta:
|
||||
|
@ -54,7 +54,7 @@ class SourceStageView(ChallengeStageView):
|
||||
def create_flow_token(self) -> FlowToken:
|
||||
"""Save the current flow state in a token that can be used to resume this flow"""
|
||||
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()
|
||||
current_stage: SourceStage = self.executor.current_stage
|
||||
identifier = slugify(f"ak-source-stage-{current_stage.name}-{str(uuid4())}")
|
||||
|
@ -304,6 +304,5 @@ class TestAuthenticatorWebAuthnStage(FlowTestCase):
|
||||
SERVER_PORT="9000",
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
print(response.content)
|
||||
self.assertStageRedirects(response, reverse("authentik_core:root-redirect"))
|
||||
self.assertTrue(WebAuthnDevice.objects.filter(user=self.user).exists())
|
||||
|
@ -49,7 +49,7 @@ export class FlowErrorStage extends BaseStage<FlowErrorChallenge, FlowChallengeR
|
||||
<ak-empty-state
|
||||
icon="fa-times"
|
||||
header=${this.challenge.error
|
||||
? html`${this.challenge.error}`
|
||||
? this.challenge.error
|
||||
: msg("Something went wrong! Please try again later.")}
|
||||
>
|
||||
<div slot="body">
|
||||
|
Reference in New Issue
Block a user