web/user: fix wrong device being selected in user's mfa update form
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
8d5460a132
commit
15ab11be70
|
@ -1,7 +1,7 @@
|
|||
import { t } from "@lingui/macro";
|
||||
|
||||
import { TemplateResult, html } from "lit";
|
||||
import { customElement } from "lit/decorators";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { ifDefined } from "lit/directives/if-defined";
|
||||
|
||||
import { AuthenticatorsApi, Device } from "@goauthentik/api";
|
||||
|
@ -12,9 +12,14 @@ import { ModelForm } from "../../../elements/forms/ModelForm";
|
|||
|
||||
@customElement("ak-user-mfa-form")
|
||||
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) => device.pk === pk)[0];
|
||||
return devices.filter((device) => {
|
||||
return device.pk === pk && device.type === this.deviceType;
|
||||
})[0];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,8 @@ export class MFADevicesPage extends Table<Device> {
|
|||
<ak-forms-modal>
|
||||
<span slot="submit">${t`Update`}</span>
|
||||
<span slot="header">${t`Update Device`}</span>
|
||||
<ak-user-mfa-form slot="form" .instancePk=${item.pk}> </ak-user-mfa-form>
|
||||
<ak-user-mfa-form slot="form" deviceType=${item.type} .instancePk=${item.pk}>
|
||||
</ak-user-mfa-form>
|
||||
<button slot="trigger" class="pf-c-button pf-m-plain">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
|
|
Reference in New Issue