Repository navigation
Auth/PM-46028 - Add core AccountDeletionService using LogoutService - #24288
JaredSnider-Bitwarden wants to merge 10 commits into
Conversation
…utService Adds AccountDeletionService and DefaultAccountDeletionService in libs/common/src/auth/account-deletion. The service builds the verification request, deletes the account through AccountApiService, then logs the user out through LogoutService with the accountDeleted reason. On failure it logs the error, rethrows, and does not log out. AccountApiService.deleteAccount now takes the user ID and a built SecretVerificationRequest and only sends DELETE /accounts, authenticated as that user. It no longer depends on AccountService or UserVerificationService. Removes AccountService.delete(), which sent a raw logout message with no user or reason, along with the MessagingService and LogService dependencies that only it used. Updates the hand-built AccountServiceImplementation constructions in the browser background, desktop main process, and CLI. DeleteAccountDialogComponent now calls AccountDeletionService with the active user.
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the new |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #24288 +/- ##
==========================================
+ Coverage 63.31% 63.32% +0.01%
==========================================
Files 5006 5009 +3
Lines 162917 162924 +7
Branches 26287 26286 -1
==========================================
+ Hits 103156 103179 +23
+ Misses 52765 52750 -15
+ Partials 6996 6995 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| async deleteAccount(verification: Verification): Promise<void> { | ||
| try { | ||
| const verificationRequest = await this.userVerificationService.buildRequest(verification); |
There was a problem hiding this comment.
Why buildRequest moved out of AccountApiService.deleteAccount: the API layer should only send HTTP requests.
buildRequest()is not transport work. For a master password, it reads the user's KDF settings and salt and derives the authentication hash.- The API service no longer depends on
UserVerificationServiceorInternalAccountService, and an API call no longer logs the user out. - It matches the other methods in
AccountApiService, which take a finished request model and send it. DefaultAccountDeletionServicenow does the orchestration (build the request, delete, log out).WebAuthnLoginAdminServiceuses the same pattern.
Changes in this PR impact the Autofill experience of the browser clientBIT has tested the core experience with these changes and the feature flag configuration used by ✅ Fortunately, these BIT tests have passed! 🎉 |
Changes in this PR impact the Autofill experience of the browser clientBIT has tested the core experience with these changes and all feature flags disabled. ✅ Fortunately, these BIT tests have passed! 🎉 |
…-deletion-service # Conflicts: # libs/common/src/auth/abstractions/account-api.service.ts # libs/common/src/auth/services/account-api.service.ts
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-46028
📔 Objective
Account deletion logged the user out through
AccountService.delete(), which sent a rawlogoutmessage with no user ID or reason. This adds a coreAccountDeletionServiceinlibs/common/src/auth/account-deletionthat owns the deletion and logs out throughLogoutService.AccountDeletionService.deleteAccount(userId, verification)builds the verification request, deletes the account, then callslogoutService.logout(userId, "accountDeleted"). On failure it logs the error, rethrows, and the user stays logged in.AccountApiService.deleteAccount(userId, request)now only sendsDELETE /accounts, authenticated as that user. It no longer depends onAccountServiceorUserVerificationService.AccountService.delete()is removed, along with itsMessagingServiceandLogServicedependencies. The browser background, desktop main process, and CLI constructAccountServiceby hand and are updated.DeleteAccountDialogComponentcalls the new service with the active user.No behavior change, except that the logout now logs the
accountDeletedreason.📸 Screenshots
Web Delete Account works
PM-46028.-.Web.delete.acct.works.mov
Desktop Delete Account works
PM-46028.-.Desktop.delete.acct.works.mov