From f46ea8417778e66f3b00faba70afb1f587e8b0ef Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Sat, 29 Mar 2025 20:49:09 -0700 Subject: [PATCH] update injection of ChangePasswordService --- .../src/app/auth/core/services/change-password/index.ts | 1 + .../change-password/web-change-password.service.ts | 4 ++-- apps/web/src/app/auth/core/services/index.ts | 1 + apps/web/src/app/core/core.module.ts | 7 +++++++ libs/angular/src/services/jslib-services.module.ts | 7 +++++++ 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 apps/web/src/app/auth/core/services/change-password/index.ts diff --git a/apps/web/src/app/auth/core/services/change-password/index.ts b/apps/web/src/app/auth/core/services/change-password/index.ts new file mode 100644 index 00000000000..9b2aa1c0143 --- /dev/null +++ b/apps/web/src/app/auth/core/services/change-password/index.ts @@ -0,0 +1 @@ +export * from "./web-change-password.service"; diff --git a/apps/web/src/app/auth/core/services/change-password/web-change-password.service.ts b/apps/web/src/app/auth/core/services/change-password/web-change-password.service.ts index 15d8f132af8..51bf6c3a238 100644 --- a/apps/web/src/app/auth/core/services/change-password/web-change-password.service.ts +++ b/apps/web/src/app/auth/core/services/change-password/web-change-password.service.ts @@ -4,13 +4,13 @@ import { ChangePasswordService, DefaultChangePasswordService } from "@bitwarden/ import { Account } from "@bitwarden/common/auth/abstractions/account.service"; import { UserKeyRotationService } from "@bitwarden/web-vault/app/key-management/key-rotation/user-key-rotation.service"; -export class WebChangePasswordComponent +export class WebChangePasswordService extends DefaultChangePasswordService implements ChangePasswordService { userKeyRotationService = inject(UserKeyRotationService); - async rotateUserKeyMasterPasswordAndEncryptedData( + override async rotateUserKeyMasterPasswordAndEncryptedData( currentPassword: string, newPassword: string, user: Account, diff --git a/apps/web/src/app/auth/core/services/index.ts b/apps/web/src/app/auth/core/services/index.ts index 11c8dd98872..5539e3b76ea 100644 --- a/apps/web/src/app/auth/core/services/index.ts +++ b/apps/web/src/app/auth/core/services/index.ts @@ -1,3 +1,4 @@ +export * from "./change-password"; export * from "./login"; export * from "./login-decryption-options"; export * from "./webauthn-login"; diff --git a/apps/web/src/app/core/core.module.ts b/apps/web/src/app/core/core.module.ts index 06a91895eb8..5bd6d893f4f 100644 --- a/apps/web/src/app/core/core.module.ts +++ b/apps/web/src/app/core/core.module.ts @@ -37,6 +37,7 @@ import { TwoFactorAuthDuoComponentService, } from "@bitwarden/auth/angular"; import { + ChangePasswordService, InternalUserDecryptionOptionsServiceAbstraction, LoginEmailService, } from "@bitwarden/auth/common"; @@ -111,6 +112,7 @@ import { DefaultSshImportPromptService, SshImportPromptService } from "@bitwarde import { flagEnabled } from "../../utils/flags"; import { PolicyListService } from "../admin-console/core/policy-list.service"; import { + WebChangePasswordService, WebSetPasswordJitService, WebRegistrationFinishService, WebLoginComponentService, @@ -380,6 +382,11 @@ const safeProviders: SafeProvider[] = [ useClass: DefaultSshImportPromptService, deps: [DialogService, ToastService, PlatformUtilsService, I18nServiceAbstraction], }), + safeProvider({ + provide: ChangePasswordService, + useClass: WebChangePasswordService, + deps: [], + }), ]; @NgModule({ diff --git a/libs/angular/src/services/jslib-services.module.ts b/libs/angular/src/services/jslib-services.module.ts index 3cce9b5357e..9b675bd1f98 100644 --- a/libs/angular/src/services/jslib-services.module.ts +++ b/libs/angular/src/services/jslib-services.module.ts @@ -46,6 +46,8 @@ import { PinServiceAbstraction, UserDecryptionOptionsService, UserDecryptionOptionsServiceAbstraction, + ChangePasswordService, + DefaultChangePasswordService, } from "@bitwarden/auth/common"; import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service"; import { AuditService as AuditServiceAbstraction } from "@bitwarden/common/abstractions/audit.service"; @@ -1505,6 +1507,11 @@ const safeProviders: SafeProvider[] = [ useClass: MasterPasswordApiService, deps: [ApiServiceAbstraction, LogService], }), + safeProvider({ + provide: ChangePasswordService, + useClass: DefaultChangePasswordService, + deps: [], + }), ]; @NgModule({