stages/user_logout: migrate to web
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
fb9a4ec461
commit
128af67011
|
@ -1,16 +0,0 @@
|
||||||
"""authentik flows logout forms"""
|
|
||||||
from django import forms
|
|
||||||
|
|
||||||
from authentik.stages.user_logout.models import UserLogoutStage
|
|
||||||
|
|
||||||
|
|
||||||
class UserLogoutStageForm(forms.ModelForm):
|
|
||||||
"""Form to create/edit UserLogoutStage instances"""
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
|
|
||||||
model = UserLogoutStage
|
|
||||||
fields = ["name"]
|
|
||||||
widgets = {
|
|
||||||
"name": forms.TextInput(),
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""logout stage models"""
|
"""logout stage models"""
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
from django.forms import ModelForm
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from rest_framework.serializers import BaseSerializer
|
from rest_framework.serializers import BaseSerializer
|
||||||
|
@ -25,10 +24,8 @@ class UserLogoutStage(Stage):
|
||||||
return UserLogoutStageView
|
return UserLogoutStageView
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def form(self) -> Type[ModelForm]:
|
def component(self) -> str:
|
||||||
from authentik.stages.user_logout.forms import UserLogoutStageForm
|
return "ak-stage-user-logout-form"
|
||||||
|
|
||||||
return UserLogoutStageForm
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
|
|
56
web/src/pages/stages/user_logout/UserLogoutStageForm.ts
Normal file
56
web/src/pages/stages/user_logout/UserLogoutStageForm.ts
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import { UserLogoutStage, 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-user-logout-form")
|
||||||
|
export class UserLogoutStageForm extends Form<UserLogoutStage> {
|
||||||
|
|
||||||
|
set stageUUID(value: string) {
|
||||||
|
new StagesApi(DEFAULT_CONFIG).stagesUserLogoutRead({
|
||||||
|
stageUuid: value,
|
||||||
|
}).then(stage => {
|
||||||
|
this.stage = stage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@property({attribute: false})
|
||||||
|
stage?: UserLogoutStage;
|
||||||
|
|
||||||
|
getSuccessMessage(): string {
|
||||||
|
if (this.stage) {
|
||||||
|
return gettext("Successfully updated stage.");
|
||||||
|
} else {
|
||||||
|
return gettext("Successfully created stage.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
send = (data: UserLogoutStage): Promise<UserLogoutStage> => {
|
||||||
|
if (this.stage) {
|
||||||
|
return new StagesApi(DEFAULT_CONFIG).stagesUserLogoutUpdate({
|
||||||
|
stageUuid: this.stage.pk || "",
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return new StagesApi(DEFAULT_CONFIG).stagesUserLogoutCreate({
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
renderForm(): TemplateResult {
|
||||||
|
return html`<form class="pf-c-form pf-m-horizontal">
|
||||||
|
<ak-form-element-horizontal
|
||||||
|
label=${gettext("Name")}
|
||||||
|
?required=${true}
|
||||||
|
name="name">
|
||||||
|
<input type="text" value="${ifDefined(this.stage?.name || "")}" class="pf-c-form-control" required>
|
||||||
|
</ak-form-element-horizontal>
|
||||||
|
</form>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in a new issue