web/admin: fix deletion of authenticator not reloading the state correctly
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
56450887ca
commit
b7f4d15a94
|
@ -1,5 +1,5 @@
|
||||||
import { t } from "@lingui/macro";
|
import { t } from "@lingui/macro";
|
||||||
import { CSSResult, customElement, html, LitElement, TemplateResult } from "lit-element";
|
import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||||
|
|
||||||
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
||||||
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
||||||
|
@ -27,6 +27,7 @@ import "./settings/UserSettingsAuthenticatorTOTP";
|
||||||
import "./settings/UserSettingsAuthenticatorWebAuthn";
|
import "./settings/UserSettingsAuthenticatorWebAuthn";
|
||||||
import "./settings/UserSettingsPassword";
|
import "./settings/UserSettingsPassword";
|
||||||
import "./settings/SourceSettingsOAuth";
|
import "./settings/SourceSettingsOAuth";
|
||||||
|
import { EVENT_REFRESH } from "../../constants";
|
||||||
|
|
||||||
@customElement("ak-user-settings")
|
@customElement("ak-user-settings")
|
||||||
export class UserSettingsPage extends LitElement {
|
export class UserSettingsPage extends LitElement {
|
||||||
|
@ -35,6 +36,24 @@ export class UserSettingsPage extends LitElement {
|
||||||
return [PFBase, PFPage, PFFlex, PFDisplay, PFGallery, PFContent, PFCard, PFDescriptionList, PFSizing, PFForm, PFFormControl, AKGlobal];
|
return [PFBase, PFPage, PFFlex, PFDisplay, PFGallery, PFContent, PFCard, PFDescriptionList, PFSizing, PFForm, PFFormControl, AKGlobal];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property()
|
||||||
|
userSettings?: Promise<UserSetting[]>;
|
||||||
|
|
||||||
|
@property()
|
||||||
|
sourceSettings?: Promise<UserSetting[]>;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.addEventListener(EVENT_REFRESH, () => {
|
||||||
|
this.firstUpdated();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
firstUpdated() {
|
||||||
|
this.userSettings = new StagesApi(DEFAULT_CONFIG).stagesAllUserSettingsList();
|
||||||
|
this.sourceSettings = new SourcesApi(DEFAULT_CONFIG).sourcesAllUserSettingsList();
|
||||||
|
}
|
||||||
|
|
||||||
renderStageSettings(stage: UserSetting): TemplateResult {
|
renderStageSettings(stage: UserSetting): TemplateResult {
|
||||||
switch (stage.component) {
|
switch (stage.component) {
|
||||||
case "ak-user-settings-authenticator-webauthn":
|
case "ak-user-settings-authenticator-webauthn":
|
||||||
|
@ -82,14 +101,14 @@ export class UserSettingsPage extends LitElement {
|
||||||
<section slot="page-tokens" data-tab-title="${t`Tokens`}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
<section slot="page-tokens" data-tab-title="${t`Tokens`}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
<ak-user-token-list></ak-user-token-list>
|
<ak-user-token-list></ak-user-token-list>
|
||||||
</section>
|
</section>
|
||||||
${until(new StagesApi(DEFAULT_CONFIG).stagesAllUserSettingsList().then((stages) => {
|
${until(this.userSettings?.then((stages) => {
|
||||||
return stages.map((stage) => {
|
return stages.map((stage) => {
|
||||||
return html`<section slot="page-${stage.objectUid}" data-tab-title="${ifDefined(stage.title)}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
return html`<section slot="page-${stage.objectUid}" data-tab-title="${ifDefined(stage.title)}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
${this.renderStageSettings(stage)}
|
${this.renderStageSettings(stage)}
|
||||||
</section>`;
|
</section>`;
|
||||||
});
|
});
|
||||||
}))}
|
}))}
|
||||||
${until(new SourcesApi(DEFAULT_CONFIG).sourcesAllUserSettingsList().then((source) => {
|
${until(this.sourceSettings?.then((source) => {
|
||||||
return source.map((stage) => {
|
return source.map((stage) => {
|
||||||
return html`<section slot="page-${stage.objectUid}" data-tab-title="${ifDefined(stage.title)}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
return html`<section slot="page-${stage.objectUid}" data-tab-title="${ifDefined(stage.title)}" class="pf-c-page__main-section pf-m-no-padding-mobile">
|
||||||
${this.renderSourceSettings(stage)}
|
${this.renderSourceSettings(stage)}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { customElement, html, TemplateResult } from "lit-element";
|
||||||
import { until } from "lit-html/directives/until";
|
import { until } from "lit-html/directives/until";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { BaseUserSettings } from "./BaseUserSettings";
|
import { BaseUserSettings } from "./BaseUserSettings";
|
||||||
|
import { EVENT_REFRESH } from "../../../constants";
|
||||||
|
|
||||||
@customElement("ak-user-settings-authenticator-duo")
|
@customElement("ak-user-settings-authenticator-duo")
|
||||||
export class UserSettingsAuthenticatorDuo extends BaseUserSettings {
|
export class UserSettingsAuthenticatorDuo extends BaseUserSettings {
|
||||||
|
@ -27,7 +28,12 @@ export class UserSettingsAuthenticatorDuo extends BaseUserSettings {
|
||||||
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsDuoDestroy({
|
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsDuoDestroy({
|
||||||
id: devices.results[0].pk || 0
|
id: devices.results[0].pk || 0
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.requestUpdate();
|
this.dispatchEvent(
|
||||||
|
new CustomEvent(EVENT_REFRESH, {
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { until } from "lit-html/directives/until";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { STATIC_TOKEN_STYLE } from "../../../flows/stages/authenticator_static/AuthenticatorStaticStage";
|
import { STATIC_TOKEN_STYLE } from "../../../flows/stages/authenticator_static/AuthenticatorStaticStage";
|
||||||
import { BaseUserSettings } from "./BaseUserSettings";
|
import { BaseUserSettings } from "./BaseUserSettings";
|
||||||
|
import { EVENT_REFRESH } from "../../../constants";
|
||||||
|
|
||||||
@customElement("ak-user-settings-authenticator-static")
|
@customElement("ak-user-settings-authenticator-static")
|
||||||
export class UserSettingsAuthenticatorStatic extends BaseUserSettings {
|
export class UserSettingsAuthenticatorStatic extends BaseUserSettings {
|
||||||
|
@ -42,7 +43,12 @@ export class UserSettingsAuthenticatorStatic extends BaseUserSettings {
|
||||||
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsStaticDestroy({
|
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsStaticDestroy({
|
||||||
id: devices.results[0].pk || 0
|
id: devices.results[0].pk || 0
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.requestUpdate();
|
this.dispatchEvent(
|
||||||
|
new CustomEvent(EVENT_REFRESH, {
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { customElement, html, TemplateResult } from "lit-element";
|
||||||
import { until } from "lit-html/directives/until";
|
import { until } from "lit-html/directives/until";
|
||||||
import { DEFAULT_CONFIG } from "../../../api/Config";
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
import { BaseUserSettings } from "./BaseUserSettings";
|
import { BaseUserSettings } from "./BaseUserSettings";
|
||||||
|
import { EVENT_REFRESH } from "../../../constants";
|
||||||
|
|
||||||
@customElement("ak-user-settings-authenticator-totp")
|
@customElement("ak-user-settings-authenticator-totp")
|
||||||
export class UserSettingsAuthenticatorTOTP extends BaseUserSettings {
|
export class UserSettingsAuthenticatorTOTP extends BaseUserSettings {
|
||||||
|
@ -27,7 +28,12 @@ export class UserSettingsAuthenticatorTOTP extends BaseUserSettings {
|
||||||
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsTotpDestroy({
|
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsTotpDestroy({
|
||||||
id: devices.results[0].pk || 0
|
id: devices.results[0].pk || 0
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.requestUpdate();
|
this.dispatchEvent(
|
||||||
|
new CustomEvent(EVENT_REFRESH, {
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import "../../../elements/forms/Form";
|
||||||
import "../../../elements/forms/ModalForm";
|
import "../../../elements/forms/ModalForm";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
import { ifDefined } from "lit-html/directives/if-defined";
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
|
import { EVENT_REFRESH } from "../../../constants";
|
||||||
|
|
||||||
@customElement("ak-user-settings-authenticator-webauthn")
|
@customElement("ak-user-settings-authenticator-webauthn")
|
||||||
export class UserSettingsAuthenticatorWebAuthn extends BaseUserSettings {
|
export class UserSettingsAuthenticatorWebAuthn extends BaseUserSettings {
|
||||||
|
@ -28,7 +29,12 @@ export class UserSettingsAuthenticatorWebAuthn extends BaseUserSettings {
|
||||||
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsWebauthnDestroy({
|
return new AuthenticatorsApi(DEFAULT_CONFIG).authenticatorsWebauthnDestroy({
|
||||||
id: device.pk || 0
|
id: device.pk || 0
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.requestUpdate();
|
this.dispatchEvent(
|
||||||
|
new CustomEvent(EVENT_REFRESH, {
|
||||||
|
bubbles: true,
|
||||||
|
composed: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
<button slot="trigger" class="pf-c-button pf-m-danger">
|
<button slot="trigger" class="pf-c-button pf-m-danger">
|
||||||
|
|
Reference in a new issue