Skip to content

Commit

Permalink
enterprise/stages/source: fix error when creating source stage from b…
Browse files Browse the repository at this point in the history
…lueprint (#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>
  • Loading branch information
BeryJu committed May 22, 2024
1 parent ef2e1ad commit 347746c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions authentik/enterprise/stages/source/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ def validate_source(self, _source: Source) -> Source:
source = Source.objects.filter(pk=_source.pk).select_subclasses().first()
if not source:
raise ValidationError("Invalid source")
login_button = source.ui_login_button(self.context["request"])
if not login_button:
raise ValidationError("Invalid source selected, only web-based sources are supported.")
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."
)
return source

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion authentik/enterprise/stages/source/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_challenge(self, *args, **kwargs) -> Challenge:
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())}")
Expand Down
1 change: 0 additions & 1 deletion authentik/stages/authenticator_webauthn/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,5 @@ def test_register_restricted_device_type_allow_unknown(self):
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())
2 changes: 1 addition & 1 deletion web/src/flow/stages/FlowErrorStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 347746c

Please sign in to comment.