web/admin: always override send method instead of assigning (#5426)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L
2023-04-30 19:55:29 +03:00
committed by GitHub
parent bb8b87fcb3
commit fef841a458
66 changed files with 137 additions and 138 deletions

View File

@ -15,19 +15,18 @@ export class MFADeviceForm extends ModelForm<Device, number> {
@property()
deviceType!: string;
loadInstance(pk: number): Promise<Device> {
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsAllList().then((devices) => {
return devices.filter((device) => {
return device.pk === pk && device.type === this.deviceType;
})[0];
});
async loadInstance(pk: number): Promise<Device> {
const devices = await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsAllList();
return devices.filter((device) => {
return device.pk === pk && device.type === this.deviceType;
})[0];
}
getSuccessMessage(): string {
return t`Successfully updated device.`;
}
send = async (device: Device): Promise<Device> => {
async send(device: Device): Promise<Device> {
switch (this.instance?.type) {
case "authentik_stages_authenticator_duo.DuoDevice":
await new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsDuoUpdate({
@ -63,7 +62,7 @@ export class MFADeviceForm extends ModelForm<Device, number> {
break;
}
return device;
};
}
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">

View File

@ -29,7 +29,7 @@ export class UserTokenForm extends ModelForm<Token, string> {
}
}
send = (data: Token): Promise<Token> => {
async send(data: Token): Promise<Token> {
if (this.instance) {
return new CoreApi(DEFAULT_CONFIG).coreTokensUpdate({
identifier: this.instance.identifier,
@ -41,7 +41,7 @@ export class UserTokenForm extends ModelForm<Token, string> {
tokenRequest: data,
});
}
};
}
renderForm(): TemplateResult {
return html`<form class="pf-c-form pf-m-horizontal">