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 { t } from "@lingui/macro";
|
||||||
|
|
||||||
import { TemplateResult, html } from "lit";
|
import { TemplateResult, html } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
import { ifDefined } from "lit/directives/if-defined";
|
import { ifDefined } from "lit/directives/if-defined";
|
||||||
|
|
||||||
import { AuthenticatorsApi, Device } from "@goauthentik/api";
|
import { AuthenticatorsApi, Device } from "@goauthentik/api";
|
||||||
|
@ -12,9 +12,14 @@ import { ModelForm } from "../../../elements/forms/ModelForm";
|
||||||
|
|
||||||
@customElement("ak-user-mfa-form")
|
@customElement("ak-user-mfa-form")
|
||||||
export class MFADeviceForm extends ModelForm<Device, number> {
|
export class MFADeviceForm extends ModelForm<Device, number> {
|
||||||
|
@property()
|
||||||
|
deviceType!: string;
|
||||||
|
|
||||||
loadInstance(pk: number): Promise<Device> {
|
loadInstance(pk: number): Promise<Device> {
|
||||||
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsAllList().then((devices) => {
|
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>
|
<ak-forms-modal>
|
||||||
<span slot="submit">${t`Update`}</span>
|
<span slot="submit">${t`Update`}</span>
|
||||||
<span slot="header">${t`Update Device`}</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">
|
<button slot="trigger" class="pf-c-button pf-m-plain">
|
||||||
<i class="fas fa-edit"></i>
|
<i class="fas fa-edit"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
Reference in New Issue