stages/prompt: fix type in Prompt not having enum set
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
73d991e75a
commit
af83308fd4
|
@ -176,6 +176,7 @@ SPECTACULAR_SETTINGS = {
|
||||||
"FlowDesignationEnum": "authentik.flows.models.FlowDesignation",
|
"FlowDesignationEnum": "authentik.flows.models.FlowDesignation",
|
||||||
"PolicyEngineMode": "authentik.policies.models.PolicyEngineMode",
|
"PolicyEngineMode": "authentik.policies.models.PolicyEngineMode",
|
||||||
"ProxyMode": "authentik.providers.proxy.models.ProxyMode",
|
"ProxyMode": "authentik.providers.proxy.models.ProxyMode",
|
||||||
|
"PromptTypeEnum": "authentik.stages.prompt.models.FieldTypes",
|
||||||
},
|
},
|
||||||
"ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False,
|
"ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False,
|
||||||
"POSTPROCESSING_HOOKS": [
|
"POSTPROCESSING_HOOKS": [
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.http import HttpRequest, HttpResponse
|
||||||
from django.http.request import QueryDict
|
from django.http.request import QueryDict
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from guardian.shortcuts import get_anonymous_user
|
from guardian.shortcuts import get_anonymous_user
|
||||||
from rest_framework.fields import BooleanField, CharField, IntegerField
|
from rest_framework.fields import BooleanField, CharField, ChoiceField, IntegerField
|
||||||
from rest_framework.serializers import ValidationError
|
from rest_framework.serializers import ValidationError
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class StagePromptSerializer(PassiveSerializer):
|
||||||
|
|
||||||
field_key = CharField()
|
field_key = CharField()
|
||||||
label = CharField(allow_blank=True)
|
label = CharField(allow_blank=True)
|
||||||
type = CharField()
|
type = ChoiceField(choices=FieldTypes.choices)
|
||||||
required = BooleanField()
|
required = BooleanField()
|
||||||
placeholder = CharField(allow_blank=True)
|
placeholder = CharField(allow_blank=True)
|
||||||
order = IntegerField()
|
order = IntegerField()
|
||||||
|
|
|
@ -29646,7 +29646,7 @@ components:
|
||||||
label:
|
label:
|
||||||
type: string
|
type: string
|
||||||
type:
|
type:
|
||||||
type: string
|
$ref: '#/components/schemas/PromptTypeEnum'
|
||||||
required:
|
required:
|
||||||
type: boolean
|
type: boolean
|
||||||
placeholder:
|
placeholder:
|
||||||
|
|
|
@ -13,7 +13,12 @@ import PFLogin from "@patternfly/patternfly/components/Login/login.css";
|
||||||
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
|
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
|
||||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||||
|
|
||||||
import { PromptChallenge, PromptChallengeResponseRequest, StagePrompt } from "@goauthentik/api";
|
import {
|
||||||
|
PromptChallenge,
|
||||||
|
PromptChallengeResponseRequest,
|
||||||
|
PromptTypeEnum,
|
||||||
|
StagePrompt,
|
||||||
|
} from "@goauthentik/api";
|
||||||
|
|
||||||
import "../../../elements/Divider";
|
import "../../../elements/Divider";
|
||||||
import "../../../elements/EmptyState";
|
import "../../../elements/EmptyState";
|
||||||
|
@ -28,7 +33,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
|
|
||||||
renderPromptInner(prompt: StagePrompt): string {
|
renderPromptInner(prompt: StagePrompt): string {
|
||||||
switch (prompt.type) {
|
switch (prompt.type) {
|
||||||
case "text":
|
case PromptTypeEnum.Text:
|
||||||
return `<input
|
return `<input
|
||||||
type="text"
|
type="text"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
|
@ -37,7 +42,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}
|
?required=${prompt.required}
|
||||||
value="">`;
|
value="">`;
|
||||||
case "username":
|
case PromptTypeEnum.Username:
|
||||||
return `<input
|
return `<input
|
||||||
type="text"
|
type="text"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
|
@ -46,7 +51,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}
|
?required=${prompt.required}
|
||||||
value="">`;
|
value="">`;
|
||||||
case "email":
|
case PromptTypeEnum.Email:
|
||||||
return `<input
|
return `<input
|
||||||
type="email"
|
type="email"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
|
@ -54,7 +59,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}
|
?required=${prompt.required}
|
||||||
value="">`;
|
value="">`;
|
||||||
case "password":
|
case PromptTypeEnum.Password:
|
||||||
return `<input
|
return `<input
|
||||||
type="password"
|
type="password"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
|
@ -62,37 +67,37 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
autocomplete="new-password"
|
autocomplete="new-password"
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}>`;
|
?required=${prompt.required}>`;
|
||||||
case "number":
|
case PromptTypeEnum.Number:
|
||||||
return `<input
|
return `<input
|
||||||
type="number"
|
type="number"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
placeholder="${prompt.placeholder}"
|
placeholder="${prompt.placeholder}"
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}>`;
|
?required=${prompt.required}>`;
|
||||||
case "date":
|
case PromptTypeEnum.Date:
|
||||||
return `<input
|
return `<input
|
||||||
type="date"
|
type="date"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
placeholder="${prompt.placeholder}"
|
placeholder="${prompt.placeholder}"
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}>`;
|
?required=${prompt.required}>`;
|
||||||
case "date-time":
|
case PromptTypeEnum.DateTime:
|
||||||
return `<input
|
return `<input
|
||||||
type="datetime"
|
type="datetime"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
placeholder="${prompt.placeholder}"
|
placeholder="${prompt.placeholder}"
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}>`;
|
?required=${prompt.required}>`;
|
||||||
case "separator":
|
case PromptTypeEnum.Separator:
|
||||||
return `<ak-divider>${prompt.placeholder}</ak-divider>`;
|
return `<ak-divider>${prompt.placeholder}</ak-divider>`;
|
||||||
case "hidden":
|
case PromptTypeEnum.Hidden:
|
||||||
return `<input
|
return `<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
name="${prompt.fieldKey}"
|
name="${prompt.fieldKey}"
|
||||||
value="${prompt.placeholder}"
|
value="${prompt.placeholder}"
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}>`;
|
?required=${prompt.required}>`;
|
||||||
case "static":
|
case PromptTypeEnum.Static:
|
||||||
return `<p>${prompt.placeholder}</p>`;
|
return `<p>${prompt.placeholder}</p>`;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -114,7 +119,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
>
|
>
|
||||||
${this.challenge.fields.map((prompt) => {
|
${this.challenge.fields.map((prompt) => {
|
||||||
// Checkbox is rendered differently
|
// Checkbox is rendered differently
|
||||||
if (prompt.type === "checkbox") {
|
if (prompt.type === PromptTypeEnum.Checkbox) {
|
||||||
return html`<div class="pf-c-check">
|
return html`<div class="pf-c-check">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
@ -132,9 +137,9 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
}
|
}
|
||||||
// Special types that aren't rendered in a wrapper
|
// Special types that aren't rendered in a wrapper
|
||||||
if (
|
if (
|
||||||
prompt.type === "static" ||
|
prompt.type === PromptTypeEnum.Static ||
|
||||||
prompt.type === "hidden" ||
|
prompt.type === PromptTypeEnum.Hidden ||
|
||||||
prompt.type === "separator"
|
prompt.type === PromptTypeEnum.Separator
|
||||||
) {
|
) {
|
||||||
return unsafeHTML(this.renderPromptInner(prompt));
|
return unsafeHTML(this.renderPromptInner(prompt));
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue