
When submitting some forms with the Enter key instead of clicking "Confirm"/etc, the form would not get submitted correctly This would in the worst case is when setting a user's password, where the new password can end up in the URL, but the password was not actually saved to the user. Signed-off-by: Jens Langhammer <jens@goauthentik.io> # Conflicts: # web/src/admin/applications/ApplicationCheckAccessForm.ts # web/src/admin/crypto/CertificateGenerateForm.ts # web/src/admin/flows/FlowImportForm.ts # web/src/admin/groups/RelatedGroupList.ts # web/src/admin/policies/PolicyTestForm.ts # web/src/admin/property-mappings/PropertyMappingTestForm.ts # web/src/admin/providers/saml/SAMLProviderImportForm.ts # web/src/admin/users/RelatedUserList.ts # web/src/admin/users/ServiceAccountForm.ts # web/src/admin/users/UserPasswordForm.ts # web/src/admin/users/UserResetEmailForm.ts
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { groupBy } from "@goauthentik/common/utils";
|
|
import { Form } from "@goauthentik/elements/forms/Form";
|
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
|
import "@goauthentik/elements/forms/SearchSelect";
|
|
|
|
import { t } from "@lingui/macro";
|
|
|
|
import { TemplateResult, html } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import {
|
|
CoreApi,
|
|
CoreUsersRecoveryEmailRetrieveRequest,
|
|
Stage,
|
|
StagesAllListRequest,
|
|
StagesApi,
|
|
User,
|
|
} from "@goauthentik/api";
|
|
|
|
@customElement("ak-user-reset-email-form")
|
|
export class UserResetEmailForm extends Form<CoreUsersRecoveryEmailRetrieveRequest> {
|
|
@property({ attribute: false })
|
|
user!: User;
|
|
|
|
getSuccessMessage(): string {
|
|
return t`Successfully sent email.`;
|
|
}
|
|
|
|
send = (data: CoreUsersRecoveryEmailRetrieveRequest): Promise<void> => {
|
|
data.id = this.user.pk;
|
|
return new CoreApi(DEFAULT_CONFIG).coreUsersRecoveryEmailRetrieve(data);
|
|
};
|
|
|
|
renderInlineForm(): TemplateResult {
|
|
return html`<ak-form-element-horizontal
|
|
label=${t`Email stage`}
|
|
?required=${true}
|
|
name="emailStage"
|
|
>
|
|
<ak-search-select
|
|
.fetchObjects=${async (query?: string): Promise<Stage[]> => {
|
|
const args: StagesAllListRequest = {
|
|
ordering: "name",
|
|
};
|
|
if (query !== undefined) {
|
|
args.search = query;
|
|
}
|
|
const stages = await new StagesApi(DEFAULT_CONFIG).stagesEmailList(args);
|
|
return stages.results;
|
|
}}
|
|
.groupBy=${(items: Stage[]) => {
|
|
return groupBy(items, (stage) => stage.verboseNamePlural);
|
|
}}
|
|
.renderElement=${(stage: Stage): string => {
|
|
return stage.name;
|
|
}}
|
|
.value=${(stage: Stage | undefined): string | undefined => {
|
|
return stage?.pk;
|
|
}}
|
|
>
|
|
</ak-search-select>
|
|
</ak-form-element-horizontal>`;
|
|
}
|
|
}
|