From e0126e9be2c5da8ca89d602c68e44698f45ac533 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:20:18 +0100 Subject: [PATCH] send deferred function to enable 2fa --- .../current-user-mfa-provider-modal.element.ts | 6 +++++- .../current-user-mfa-provider-modal.token.ts | 1 - .../current-user-mfa/current-user-mfa-modal.element.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.element.ts index e6e95cfc79..c65c521f4c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.element.ts @@ -1,4 +1,5 @@ import type { UmbMfaProviderConfigurationElementProps } from '../../types.js'; +import { UmbCurrentUserRepository } from '../../repository/index.js'; import type { UmbCurrentUserMfaProviderModalConfig } from './current-user-mfa-provider-modal.token.js'; import type { ManifestMfaLoginProvider } from '@umbraco-cms/backoffice/extension-registry'; import { customElement, html } from '@umbraco-cms/backoffice/external/lit'; @@ -11,6 +12,8 @@ export class UmbCurrentUserMfaProviderModalElement extends UmbModalBaseElement< UmbCurrentUserMfaProviderModalConfig, never > { + #currentUserRepository = new UmbCurrentUserRepository(this); + #close = () => { this._rejectModal(); }; @@ -18,7 +21,8 @@ export class UmbCurrentUserMfaProviderModalElement extends UmbModalBaseElement< get #extensionSlotProps(): UmbMfaProviderConfigurationElementProps { return { providerName: this.data!.providerName, - enableProvider: this.data!.repository.enableMfaProvider, + enableProvider: (providerName, code, secret) => + this.#currentUserRepository.enableMfaProvider(providerName, code, secret), close: this.#close, }; } diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.token.ts b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.token.ts index 54da217c0c..d795664900 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.token.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa-provider/current-user-mfa-provider-modal.token.ts @@ -3,7 +3,6 @@ import { UmbModalToken } from '@umbraco-cms/backoffice/modal'; export interface UmbCurrentUserMfaProviderModalConfig { providerName: string; - repository: UmbCurrentUserRepository; } export const UMB_CURRENT_USER_MFA_PROVIDER_MODAL = new UmbModalToken( diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa/current-user-mfa-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa/current-user-mfa-modal.element.ts index 9d5e633192..a5c7fe23cc 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa/current-user-mfa-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/modals/current-user-mfa/current-user-mfa-modal.element.ts @@ -96,7 +96,7 @@ export class UmbCurrentUserMfaModalElement extends UmbLitElement { const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT); return await modalManager .open(this, UMB_CURRENT_USER_MFA_PROVIDER_MODAL, { - data: { providerName: item.providerName, repository: this.#currentUserRepository }, + data: { providerName: item.providerName }, }) .onSubmit() .catch(() => ({}));