flows: remove stage challenge type (#10476)

* flows: remove stage challenge type

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* fix

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* improve coverage

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L
2024-07-13 18:37:29 +02:00
committed by GitHub
parent 8f7fe8e744
commit 8db1d86c6b
46 changed files with 75 additions and 255 deletions

View File

@ -20,7 +20,6 @@ import PFPage from "@patternfly/patternfly/components/Page/page.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
import {
ChallengeChoices,
ChallengeTypes,
FlowChallengeResponseRequest,
FlowErrorChallenge,
@ -116,7 +115,6 @@ export class UserSettingsFlowExecutor
body = error.message;
}
const challenge: FlowErrorChallenge = {
type: ChallengeChoices.Native,
component: "ak-stage-flow-error",
error: body,
requestId: "",
@ -146,8 +144,15 @@ export class UserSettingsFlowExecutor
if (!this.challenge) {
return html``;
}
switch (this.challenge.type) {
case ChallengeChoices.Redirect:
switch (this.challenge.component) {
case "ak-stage-prompt":
return html`<ak-user-stage-prompt
.host=${this as StageHost}
.challenge=${this.challenge}
></ak-user-stage-prompt>`;
case "xak-flow-shell":
return html`${unsafeHTML((this.challenge as ShellChallenge).body)}`;
case "xak-flow-redirect":
if ((this.challenge as RedirectChallenge).to !== "/") {
return html`<a
href="${(this.challenge as RedirectChallenge).to}"
@ -166,30 +171,16 @@ export class UserSettingsFlowExecutor
});
return html`<ak-empty-state ?loading=${true} header=${msg("Loading")}>
</ak-empty-state>`;
case ChallengeChoices.Shell:
return html`${unsafeHTML((this.challenge as ShellChallenge).body)}`;
case ChallengeChoices.Native:
switch (this.challenge.component) {
case "ak-stage-prompt":
return html`<ak-user-stage-prompt
.host=${this as StageHost}
.challenge=${this.challenge}
></ak-user-stage-prompt>`;
default:
console.debug(
`authentik/user/flows: unsupported stage type ${this.challenge.component}`,
);
return html`
<a href="/if/flow/${this.flowSlug}/" class="pf-c-button pf-m-primary">
${msg("Open settings")}
</a>
`;
}
default:
console.debug(`authentik/user/flows: unexpected data type ${this.challenge.type}`);
break;
console.debug(
`authentik/user/flows: unsupported stage type ${this.challenge.component}`,
);
return html`
<a href="/if/flow/${this.flowSlug}/" class="pf-c-button pf-m-primary">
${msg("Open settings")}
</a>
`;
}
return html``;
}
renderChallengeWrapper(): TemplateResult {