Skip to content

Auth/PM-46028 - Add core AccountDeletionService using LogoutService - #24288

Open
JaredSnider-Bitwarden wants to merge 10 commits into
mainfrom
auth/pm-46028-account-deletion-service
Open

JaredSnider-Bitwarden wants to merge 10 commits into
mainfrom
auth/pm-46028-account-deletion-service

Conversation

@JaredSnider-Bitwarden

@JaredSnider-Bitwarden JaredSnider-Bitwarden commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-46028

📔 Objective

Account deletion logged the user out through AccountService.delete(), which sent a raw logout message with no user ID or reason. This adds a core AccountDeletionService in libs/common/src/auth/account-deletion that owns the deletion and logs out through LogoutService.

  1. AccountDeletionService.deleteAccount(userId, verification) builds the verification request, deletes the account, then calls logoutService.logout(userId, "accountDeleted"). On failure it logs the error, rethrows, and the user stays logged in.
  2. AccountApiService.deleteAccount(userId, request) now only sends DELETE /accounts, authenticated as that user. It no longer depends on AccountService or UserVerificationService.
  3. AccountService.delete() is removed, along with its MessagingService and LogService dependencies. The browser background, desktop main process, and CLI construct AccountService by hand and are updated.
  4. DeleteAccountDialogComponent calls the new service with the active user.

No behavior change, except that the logout now logs the accountDeleted reason.

📸 Screenshots

Web Delete Account works
PM-46028.-.Web.delete.acct.works.mov
Desktop Delete Account works
PM-46028.-.Desktop.delete.acct.works.mov

…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.
@JaredSnider-Bitwarden JaredSnider-Bitwarden added the t:tech-debt Change Type - Tech debt label Oct 29, 2026
@JaredSnider-Bitwarden JaredSnider-Bitwarden changed the title [PM-46028] Add a core AccountDeletionService that logs out through LogoutService [PM-46028] Add core AccountDeletionService using LogoutService Oct 29, 2026
@JaredSnider-Bitwarden JaredSnider-Bitwarden added the ai-review Request a Claude code review label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the new AccountDeletionService / DefaultAccountDeletionService, the narrowed AccountApiService.deleteAccount(userId, request), the removal of AccountService.delete() and its MessagingService / LogService constructor dependencies, the Angular DI wiring, and the updated DeleteAccountDialogComponent at head ea4180027c. The deletion flow builds the verification request, sends DELETE /accounts authenticated as userId, and calls LogoutService.logout(userId, "accountDeleted") only after the delete succeeds; "accountDeleted" is an existing LogoutReason, and the logout message now carries the user ID and reason that the existing logout handlers already accept. All manual AccountServiceImplementation construction sites (browser background, CLI, desktop main, desktop spec) use the new two-argument signature, and no remaining callers use the old deleteAccount(verification) or delete() APIs.

@JaredSnider-Bitwarden JaredSnider-Bitwarden changed the title [PM-46028] Add core AccountDeletionService using LogoutService Auth/PM-46028 - Add core AccountDeletionService using LogoutService Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.32%. Comparing base (a0c8970) to head (ea41800).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...-account-dialog/delete-account-dialog.component.ts 50.00% 4 Missing ⚠️
libs/common/src/auth/account-deletion/index.ts 0.00% 2 Missing ⚠️
libs/angular/src/services/jslib-services.module.ts 0.00% 1 Missing ⚠️
...bs/common/src/auth/abstractions/account.service.ts 0.00% 1 Missing ⚠️
.../auth/account-deletion/account-deletion.service.ts 0.00% 1 Missing ⚠️
...bs/common/src/auth/services/account-api.service.ts 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


async deleteAccount(verification: Verification): Promise<void> {
try {
const verificationRequest = await this.userVerificationService.buildRequest(verification);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why buildRequest moved out of AccountApiService.deleteAccount: the API layer should only send HTTP requests.

  1. buildRequest() is not transport work. For a master password, it reads the user's KDF settings and salt and derives the authentication hash.
  2. The API service no longer depends on UserVerificationService or InternalAccountService, and an API call no longer logs the user out.
  3. It matches the other methods in AccountApiService, which take a finished request model and send it.
  4. DefaultAccountDeletionService now does the orchestration (build the request, delete, log out). WebAuthnLoginAdminService uses the same pattern.

@JaredSnider-Bitwarden
JaredSnider-Bitwarden marked this pull request as ready for review October 29, 2026 22:49
@JaredSnider-Bitwarden
JaredSnider-Bitwarden requested a review from a team as a code owner October 29, 2026 22:49
ike-kottlowski
ike-kottlowski previously approved these changes Nov 2, 2026
@bw-ghapp

bw-ghapp Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Changes in this PR impact the Autofill experience of the browser client

BIT has tested the core experience with these changes and the feature flag configuration used by vault.bitwarden.com.

✅ Fortunately, these BIT tests have passed! 🎉

@bw-ghapp

bw-ghapp Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Changes in this PR impact the Autofill experience of the browser client

BIT has tested the core experience with these changes and all feature flags disabled.

✅ Fortunately, these BIT tests have passed! 🎉

coroiu
coroiu previously approved these changes Nov 10, 2026

@coroiu coroiu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, keep 'em coming

…-deletion-service

# Conflicts:
#	libs/common/src/auth/abstractions/account-api.service.ts
#	libs/common/src/auth/services/account-api.service.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants