diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/change-password-modal.token.ts b/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/change-password-modal.token.ts index c34f51fe17..2473bd8f44 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/change-password-modal.token.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/modal/token/change-password-modal.token.ts @@ -2,7 +2,6 @@ import { UmbModalToken } from '@umbraco-cms/backoffice/modal'; export interface UmbChangePasswordModalData { userId: string; - requireOldPassword?: boolean; } export interface UmbChangePasswordModalValue { diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/user-profile-apps/user-profile-app-profile.element.ts b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/user-profile-apps/user-profile-app-profile.element.ts index d9e3e77833..510f3900fe 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/user-profile-apps/user-profile-app-profile.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/user-profile-apps/user-profile-app-profile.element.ts @@ -47,7 +47,6 @@ export class UmbUserProfileAppProfileElement extends UmbLitElement { if (!this._modalContext) return; this._modalContext.open(UMB_CHANGE_PASSWORD_MODAL, { - requireOldPassword: false, userId: this._currentUser?.id ?? '', }); } diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/modals/change-password/change-password-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/user/modals/change-password/change-password-modal.element.ts index 2548144096..81d8c222d6 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/modals/change-password/change-password-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/modals/change-password/change-password-modal.element.ts @@ -7,10 +7,10 @@ import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth'; @customElement('umb-change-password-modal') export class UmbChangePasswordModalElement extends UmbModalBaseElement { @state() - private _userName: string = ''; + private _headline: string = 'Change password'; @state() - private _headline: string = 'Change password'; + private _isCurrentUser: boolean = false; #userItemRepository = new UmbUserItemRepository(this); #authContext?: typeof UMB_AUTH_CONTEXT.TYPE; @@ -38,6 +38,29 @@ export class UmbChangePasswordModalElement extends UmbModalBaseElement { + this.#authContext = instance; + this.#setIsCurrentUser(); + }); + } + + async #setIsCurrentUser() { + if (!this.data?.userId) { + this._isCurrentUser = false; + return; + } + + if (!this.#authContext) { + this._isCurrentUser = false; + return; + } + + this._isCurrentUser = await this.#authContext.isUserCurrentUser(this.data.userId); + } + protected async firstUpdated(): Promise { if (!this.data?.userId) return; const { data } = await this.#userItemRepository.requestItems([this.data.userId]); @@ -53,7 +76,7 @@ export class UmbChangePasswordModalElement extends UmbModalBaseElement
- ${this.data?.requireOldPassword ? this.#renderOldPasswordInput() : nothing} + ${this._isCurrentUser ? this.#renderOldPasswordInput() : nothing} New password