diff --git a/authentik/stages/deny/forms.py b/authentik/stages/deny/forms.py deleted file mode 100644 index d1c66e646..000000000 --- a/authentik/stages/deny/forms.py +++ /dev/null @@ -1,16 +0,0 @@ -"""authentik flows deny forms""" -from django import forms - -from authentik.stages.deny.models import DenyStage - - -class DenyStageForm(forms.ModelForm): - """Form to create/edit DenyStage instances""" - - class Meta: - - model = DenyStage - fields = ["name"] - widgets = { - "name": forms.TextInput(), - } diff --git a/authentik/stages/deny/models.py b/authentik/stages/deny/models.py index 5c201de7d..b123674f3 100644 --- a/authentik/stages/deny/models.py +++ b/authentik/stages/deny/models.py @@ -25,10 +25,8 @@ class DenyStage(Stage): return DenyStageView @property - def form(self) -> Type[ModelForm]: - from authentik.stages.deny.forms import DenyStageForm - - return DenyStageForm + def component(self) -> str: + return "ak-stage-deny-form" class Meta: diff --git a/web/src/pages/stages/deny/DenyStageForm.ts b/web/src/pages/stages/deny/DenyStageForm.ts new file mode 100644 index 000000000..970f6aa87 --- /dev/null +++ b/web/src/pages/stages/deny/DenyStageForm.ts @@ -0,0 +1,56 @@ +import { DenyStage, StagesApi } from "authentik-api"; +import { gettext } from "django"; +import { customElement, property } from "lit-element"; +import { html, TemplateResult } from "lit-html"; +import { DEFAULT_CONFIG } from "../../../api/Config"; +import { Form } from "../../../elements/forms/Form"; +import { ifDefined } from "lit-html/directives/if-defined"; +import "../../../elements/forms/HorizontalFormElement"; + +@customElement("ak-stage-deny-form") +export class DenyStageForm extends Form { + + set stageUUID(value: string) { + new StagesApi(DEFAULT_CONFIG).stagesDenyRead({ + stageUuid: value, + }).then(stage => { + this.stage = stage; + }); + } + + @property({attribute: false}) + stage?: DenyStage; + + getSuccessMessage(): string { + if (this.stage) { + return gettext("Successfully updated stage."); + } else { + return gettext("Successfully created stage."); + } + } + + send = (data: DenyStage): Promise => { + if (this.stage) { + return new StagesApi(DEFAULT_CONFIG).stagesDenyUpdate({ + stageUuid: this.stage.pk || "", + data: data + }); + } else { + return new StagesApi(DEFAULT_CONFIG).stagesDenyCreate({ + data: data + }); + } + }; + + renderForm(): TemplateResult { + return html`
+ + + +
`; + } + +} diff --git a/web/src/pages/stages/user_delete/UserDeleteStageForm.ts b/web/src/pages/stages/user_delete/UserDeleteStageForm.ts index 32f6edc82..156286b3e 100644 --- a/web/src/pages/stages/user_delete/UserDeleteStageForm.ts +++ b/web/src/pages/stages/user_delete/UserDeleteStageForm.ts @@ -8,7 +8,7 @@ import { ifDefined } from "lit-html/directives/if-defined"; import "../../../elements/forms/HorizontalFormElement"; @customElement("ak-stage-user-delete-form") -export class UserLogoutStageForm extends Form { +export class UserDeleteStageForm extends Form { set stageUUID(value: string) { new StagesApi(DEFAULT_CONFIG).stagesUserDeleteRead({