mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-18 03:19:51 +03:00
41af486006
* initial Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add user type Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add external users Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add ui, add more logic, add public JWT validation key Signed-off-by: Jens Langhammer <jens@goauthentik.io> * revert to not use install_id as session jwt signing key Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * switch to PKI Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add more licensing stuff Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add install ID to form Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix bugs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start adding tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fixes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use x5c correctly Signed-off-by: Jens Langhammer <jens@goauthentik.io> * license checks Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use production CA Signed-off-by: Jens Langhammer <jens@goauthentik.io> * more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * more UI stuff Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rename to summary Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update locale, improve ui Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add direct button Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update link Signed-off-by: Jens Langhammer <jens@goauthentik.io> * format and such Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove old attributes from ldap Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove is_enterprise_licensed Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix admin interface styling issue Signed-off-by: Jens Langhammer <jens@goauthentik.io> * Update authentik/core/models.py Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com> Signed-off-by: Jens L. <jens@beryju.org> * fix default case Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Signed-off-by: Jens L. <jens@beryju.org> Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
158 lines
6.1 KiB
TypeScript
158 lines
6.1 KiB
TypeScript
import "@goauthentik/admin/users/GroupSelectModal";
|
|
import { UserTypeEnum } from "@goauthentik/api/dist/models/UserTypeEnum";
|
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { first } from "@goauthentik/common/utils";
|
|
import "@goauthentik/elements/CodeMirror";
|
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
|
import "@goauthentik/elements/forms/Radio";
|
|
import YAML from "yaml";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { CSSResult, TemplateResult, css, html } from "lit";
|
|
import { customElement } from "lit/decorators.js";
|
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
|
import { CoreApi, User } from "@goauthentik/api";
|
|
|
|
@customElement("ak-user-form")
|
|
export class UserForm extends ModelForm<User, number> {
|
|
static get styles(): CSSResult[] {
|
|
return super.styles.concat(css`
|
|
.pf-c-button.pf-m-control {
|
|
height: 100%;
|
|
}
|
|
.pf-c-form-control {
|
|
height: auto !important;
|
|
}
|
|
`);
|
|
}
|
|
|
|
loadInstance(pk: number): Promise<User> {
|
|
return new CoreApi(DEFAULT_CONFIG).coreUsersRetrieve({
|
|
id: pk,
|
|
});
|
|
}
|
|
|
|
getSuccessMessage(): string {
|
|
if (this.instance) {
|
|
return msg("Successfully updated user.");
|
|
} else {
|
|
return msg("Successfully created user.");
|
|
}
|
|
}
|
|
|
|
async send(data: User): Promise<User> {
|
|
if (this.instance?.pk) {
|
|
return new CoreApi(DEFAULT_CONFIG).coreUsersPartialUpdate({
|
|
id: this.instance.pk,
|
|
patchedUserRequest: data,
|
|
});
|
|
} else {
|
|
data.groups = [];
|
|
return new CoreApi(DEFAULT_CONFIG).coreUsersCreate({
|
|
userRequest: data,
|
|
});
|
|
}
|
|
}
|
|
|
|
renderForm(): TemplateResult {
|
|
return html`<form class="pf-c-form pf-m-horizontal">
|
|
<ak-form-element-horizontal label=${msg("Username")} ?required=${true} name="username">
|
|
<input
|
|
type="text"
|
|
value="${ifDefined(this.instance?.username)}"
|
|
class="pf-c-form-control"
|
|
required
|
|
/>
|
|
<p class="pf-c-form__helper-text">
|
|
${msg("User's primary identifier. 150 characters or fewer.")}
|
|
</p>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal label=${msg("Name")} name="name">
|
|
<input
|
|
type="text"
|
|
value="${ifDefined(this.instance?.name)}"
|
|
class="pf-c-form-control"
|
|
/>
|
|
<p class="pf-c-form__helper-text">${msg("User's display name.")}</p>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal label=${msg("User type")} ?required=${true} name="type">
|
|
<ak-radio
|
|
.options=${[
|
|
// TODO: Add better copy
|
|
{
|
|
label: "Default",
|
|
value: UserTypeEnum.Default,
|
|
default: true,
|
|
description: html`${msg("Default user")}`,
|
|
},
|
|
{
|
|
label: "External",
|
|
value: UserTypeEnum.External,
|
|
description: html`${msg("External user")}`,
|
|
},
|
|
{
|
|
label: "Service account",
|
|
value: UserTypeEnum.ServiceAccount,
|
|
description: html`${msg("Service account")}`,
|
|
},
|
|
]}
|
|
.value=${this.instance?.type}
|
|
>
|
|
</ak-radio>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal label=${msg("Email")} name="email">
|
|
<input
|
|
type="email"
|
|
autocomplete="off"
|
|
value="${ifDefined(this.instance?.email)}"
|
|
class="pf-c-form-control"
|
|
/>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal name="isActive">
|
|
<label class="pf-c-switch">
|
|
<input
|
|
class="pf-c-switch__input"
|
|
type="checkbox"
|
|
?checked=${first(this.instance?.isActive, true)}
|
|
/>
|
|
<span class="pf-c-switch__toggle">
|
|
<span class="pf-c-switch__toggle-icon">
|
|
<i class="fas fa-check" aria-hidden="true"></i>
|
|
</span>
|
|
</span>
|
|
<span class="pf-c-switch__label">${msg("Is active")}</span>
|
|
</label>
|
|
<p class="pf-c-form__helper-text">
|
|
${msg(
|
|
"Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
|
|
)}
|
|
</p>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal label=${msg("Path")} ?required=${true} name="path">
|
|
<input
|
|
type="text"
|
|
value="${first(this.instance?.path, "users")}"
|
|
class="pf-c-form-control"
|
|
required
|
|
/>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal
|
|
label=${msg("Attributes")}
|
|
?required=${true}
|
|
name="attributes"
|
|
>
|
|
<ak-codemirror
|
|
mode="yaml"
|
|
value="${YAML.stringify(first(this.instance?.attributes, {}))}"
|
|
>
|
|
</ak-codemirror>
|
|
<p class="pf-c-form__helper-text">
|
|
${msg("Set custom attributes using YAML or JSON.")}
|
|
</p>
|
|
</ak-form-element-horizontal>
|
|
</form>`;
|
|
}
|
|
}
|