import { t } from "@lingui/macro"; import { html, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; import { ifDefined } from "lit/directives/if-defined"; import { CoreApi, UserServiceAccountRequest, UserServiceAccountResponse } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../api/Config"; import { Form } from "../../elements/forms/Form"; import "../../elements/forms/HorizontalFormElement"; import { ModalForm } from "../../elements/forms/ModalForm"; @customElement("ak-user-service-account") export class ServiceAccountForm extends Form { @property({ attribute: false }) result?: UserServiceAccountResponse; getSuccessMessage(): string { return t`Successfully created user.`; } send = (data: UserServiceAccountRequest): Promise => { return new CoreApi(DEFAULT_CONFIG) .coreUsersServiceAccountCreate({ userServiceAccountRequest: data, }) .then((result) => { this.result = result; (this.parentElement as ModalForm).showSubmitButton = false; return result; }); }; resetForm(): void { super.resetForm(); this.result = undefined; } renderRequestForm(): TemplateResult { return html` ${t`Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.`} ${t`Create group`} ${t`Enabling this toggle will create a group named after the user, with the user as member.`} `; } renderResponseForm(): TemplateResult { return html` ${t`Use the username and password below to authenticate. The password can be retrieved later on the Tokens page.`} ${t`Valid for 360 days, after which the password will automatically rotate. You can copy the password from the Token List.`} `; } renderForm(): TemplateResult { if (this.result) { return this.renderResponseForm(); } return this.renderRequestForm(); } }
${t`Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.`}
${t`Enabling this toggle will create a group named after the user, with the user as member.`}
${t`Use the username and password below to authenticate. The password can be retrieved later on the Tokens page.`}
${t`Valid for 360 days, after which the password will automatically rotate. You can copy the password from the Token List.`}