diff --git a/authentik/stages/invitation/forms.py b/authentik/stages/invitation/forms.py deleted file mode 100644 index a34bbe740..000000000 --- a/authentik/stages/invitation/forms.py +++ /dev/null @@ -1,16 +0,0 @@ -"""authentik flows invitation forms""" -from django import forms - -from authentik.stages.invitation.models import InvitationStage - - -class InvitationStageForm(forms.ModelForm): - """Form to create/edit InvitationStage instances""" - - class Meta: - - model = InvitationStage - fields = ["name", "continue_flow_without_invitation"] - widgets = { - "name": forms.TextInput(), - } diff --git a/authentik/stages/invitation/models.py b/authentik/stages/invitation/models.py index 7d97a0ebb..9e013b1f6 100644 --- a/authentik/stages/invitation/models.py +++ b/authentik/stages/invitation/models.py @@ -3,7 +3,6 @@ from typing import Type from uuid import uuid4 from django.db import models -from django.forms import ModelForm from django.utils.translation import gettext_lazy as _ from django.views import View from rest_framework.serializers import BaseSerializer @@ -40,10 +39,8 @@ class InvitationStage(Stage): return InvitationStageView @property - def form(self) -> Type[ModelForm]: - from authentik.stages.invitation.forms import InvitationStageForm - - return InvitationStageForm + def component(self) -> str: + return "ak-stage-invitation-form" class Meta: diff --git a/web/src/pages/stages/captcha/CaptchaStageForm.ts b/web/src/pages/stages/captcha/CaptchaStageForm.ts index 4fbb6f2b4..747bda72c 100644 --- a/web/src/pages/stages/captcha/CaptchaStageForm.ts +++ b/web/src/pages/stages/captcha/CaptchaStageForm.ts @@ -58,15 +58,17 @@ export class CaptchaStageForm extends Form {
- +

${gettext("Public key, acquired from https://www.google.com/recaptcha/intro/v3.html.")}

- -

${gettext("Public key, acquired from https://www.google.com/recaptcha/intro/v3.html.")}

+ +

${gettext("Private key, acquired from https://www.google.com/recaptcha/intro/v3.html.")}

diff --git a/web/src/pages/stages/identification/IdentificationStageForm.ts b/web/src/pages/stages/identification/IdentificationStageForm.ts index 504413bb1..b5b5138c6 100644 --- a/web/src/pages/stages/identification/IdentificationStageForm.ts +++ b/web/src/pages/stages/identification/IdentificationStageForm.ts @@ -98,7 +98,6 @@ export class IdentificationStageForm extends Form { + ${until(new FlowsApi(DEFAULT_CONFIG).flowsInstancesList({ ordering: "pk", designation: FlowDesignationEnum.Recovery, diff --git a/web/src/pages/stages/InvitationForm.ts b/web/src/pages/stages/invitation/InvitationForm.ts similarity index 88% rename from web/src/pages/stages/InvitationForm.ts rename to web/src/pages/stages/invitation/InvitationForm.ts index aaf24e9a4..2c14a66ce 100644 --- a/web/src/pages/stages/InvitationForm.ts +++ b/web/src/pages/stages/invitation/InvitationForm.ts @@ -2,13 +2,13 @@ import { Invitation, 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 "../../elements/forms/HorizontalFormElement"; -import "../../elements/CodeMirror"; +import { DEFAULT_CONFIG } from "../../../api/Config"; +import { Form } from "../../../elements/forms/Form"; +import "../../../elements/forms/HorizontalFormElement"; +import "../../../elements/CodeMirror"; import YAML from "yaml"; -@customElement("ak-stage-invitation-form") +@customElement("ak-invitation-form") export class InvitationForm extends Form { @property({attribute: false}) diff --git a/web/src/pages/stages/InvitationListPage.ts b/web/src/pages/stages/invitation/InvitationListPage.ts similarity index 81% rename from web/src/pages/stages/InvitationListPage.ts rename to web/src/pages/stages/invitation/InvitationListPage.ts index 98bba779b..543ac8a93 100644 --- a/web/src/pages/stages/InvitationListPage.ts +++ b/web/src/pages/stages/invitation/InvitationListPage.ts @@ -1,17 +1,17 @@ import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; -import { AKResponse } from "../../api/Client"; -import { TablePage } from "../../elements/table/TablePage"; +import { AKResponse } from "../../../api/Client"; +import { TablePage } from "../../../elements/table/TablePage"; -import "../../elements/buttons/ModalButton"; -import "../../elements/buttons/SpinnerButton"; -import "../../elements/forms/DeleteForm"; -import "../../elements/forms/ModalForm"; +import "../../../elements/buttons/ModalButton"; +import "../../../elements/buttons/SpinnerButton"; +import "../../../elements/forms/DeleteForm"; +import "../../../elements/forms/ModalForm"; import "./InvitationForm"; -import { TableColumn } from "../../elements/table/Table"; -import { PAGE_SIZE } from "../../constants"; +import { TableColumn } from "../../../elements/table/Table"; +import { PAGE_SIZE } from "../../../constants"; import { Invitation, StagesApi } from "authentik-api"; -import { DEFAULT_CONFIG } from "../../api/Config"; +import { DEFAULT_CONFIG } from "../../../api/Config"; @customElement("ak-stage-invitation-list") export class InvitationListPage extends TablePage { @@ -79,8 +79,8 @@ export class InvitationListPage extends TablePage { ${gettext("Create Invitation")} - - + + diff --git a/web/src/pages/stages/invitation/InvitationStageForm.ts b/web/src/pages/stages/invitation/InvitationStageForm.ts new file mode 100644 index 000000000..ae088d2c2 --- /dev/null +++ b/web/src/pages/stages/invitation/InvitationStageForm.ts @@ -0,0 +1,73 @@ +import { InvitationStage, 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"; +import "../../../elements/forms/FormGroup"; + +@customElement("ak-stage-invitation-form") +export class InvitationStageForm extends Form { + + set stageUUID(value: string) { + new StagesApi(DEFAULT_CONFIG).stagesInvitationStagesRead({ + stageUuid: value, + }).then(stage => { + this.stage = stage; + }); + } + + @property({attribute: false}) + stage?: InvitationStage; + + getSuccessMessage(): string { + if (this.stage) { + return gettext("Successfully updated stage."); + } else { + return gettext("Successfully created stage."); + } + } + + send = (data: InvitationStage): Promise => { + if (this.stage) { + return new StagesApi(DEFAULT_CONFIG).stagesInvitationStagesUpdate({ + stageUuid: this.stage.pk || "", + data: data + }); + } else { + return new StagesApi(DEFAULT_CONFIG).stagesInvitationStagesCreate({ + data: data + }); + } + }; + + renderForm(): TemplateResult { + return html`
+ + + + + + ${gettext("Stage-specific settings")} + +
+ +
+ + +
+

${gettext("If this flag is set, this Stage will jump to the next Stage when no Invitation is given. By default this Stage will cancel the Flow when no invitation is given.")}

+
+
+
+
`; + } + +} diff --git a/web/src/pages/stages/PromptForm.ts b/web/src/pages/stages/prompt/PromptForm.ts similarity index 97% rename from web/src/pages/stages/PromptForm.ts rename to web/src/pages/stages/prompt/PromptForm.ts index 0247cce0f..83dcfd53a 100644 --- a/web/src/pages/stages/PromptForm.ts +++ b/web/src/pages/stages/prompt/PromptForm.ts @@ -2,10 +2,10 @@ import { Prompt, PromptTypeEnum, 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 { DEFAULT_CONFIG } from "../../../api/Config"; +import { Form } from "../../../elements/forms/Form"; import { ifDefined } from "lit-html/directives/if-defined"; -import "../../elements/forms/HorizontalFormElement"; +import "../../../elements/forms/HorizontalFormElement"; @customElement("ak-prompt-form") export class PromptForm extends Form { diff --git a/web/src/pages/stages/PromptListPage.ts b/web/src/pages/stages/prompt/PromptListPage.ts similarity index 87% rename from web/src/pages/stages/PromptListPage.ts rename to web/src/pages/stages/prompt/PromptListPage.ts index 786c4a443..8d3abe50c 100644 --- a/web/src/pages/stages/PromptListPage.ts +++ b/web/src/pages/stages/prompt/PromptListPage.ts @@ -1,17 +1,17 @@ import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; -import { AKResponse } from "../../api/Client"; -import { TablePage } from "../../elements/table/TablePage"; +import { AKResponse } from "../../../api/Client"; +import { TablePage } from "../../../elements/table/TablePage"; -import "../../elements/buttons/ModalButton"; -import "../../elements/buttons/SpinnerButton"; -import "../../elements/forms/DeleteForm"; -import "../../elements/forms/ModalForm"; +import "../../../elements/buttons/ModalButton"; +import "../../../elements/buttons/SpinnerButton"; +import "../../../elements/forms/DeleteForm"; +import "../../../elements/forms/ModalForm"; import "./PromptForm"; -import { TableColumn } from "../../elements/table/Table"; -import { PAGE_SIZE } from "../../constants"; +import { TableColumn } from "../../../elements/table/Table"; +import { PAGE_SIZE } from "../../../constants"; import { Prompt, StagesApi } from "authentik-api"; -import { DEFAULT_CONFIG } from "../../api/Config"; +import { DEFAULT_CONFIG } from "../../../api/Config"; @customElement("ak-stage-prompt-list") export class PromptListPage extends TablePage { diff --git a/web/src/pages/stages/prompt/PromptStageForm.ts b/web/src/pages/stages/prompt/PromptStageForm.ts index 988272e06..edc6d587f 100644 --- a/web/src/pages/stages/prompt/PromptStageForm.ts +++ b/web/src/pages/stages/prompt/PromptStageForm.ts @@ -79,7 +79,6 @@ export class PromptStageForm extends Form {
+

${gettext("Determines how long a session lasts. Default of 0 seconds means that the sessions lasts until the browser is closed. (Format: hours=-1;minutes=-2;seconds=-3).")}

diff --git a/web/src/routes.ts b/web/src/routes.ts index 1fa6759e9..248b303ec 100644 --- a/web/src/routes.ts +++ b/web/src/routes.ts @@ -21,8 +21,8 @@ import "./pages/providers/ProviderListPage"; import "./pages/providers/ProviderViewPage"; import "./pages/sources/SourcesListPage"; import "./pages/sources/SourceViewPage"; -import "./pages/stages/InvitationListPage"; -import "./pages/stages/PromptListPage"; +import "./pages/stages/invitation/InvitationListPage"; +import "./pages/stages/prompt/PromptListPage"; import "./pages/stages/StageListPage"; import "./pages/system-tasks/SystemTaskListPage"; import "./pages/tokens/TokenListPage";