mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
[EC-317] Desktop client delete user account (#3151)
* [EC-317] feat: add delete account section in settings * [EC-317] feat: add new delete account modal * [EC-317] feat: add ability to replace top-most modal * [EC-317] chore: remove unecessary lint ignore * [EC-317] fix: so delete account is closed if export vault is opened * [EC-317] feat: inital delete account design without i18n * [EC-317] feat: disabled but basic working delete functionality * [EC-317] feat: implement according to new design * [EC-317] feat: use translations * [EC-317] feat: implement working deletion * [EC-317] feat: add loading state and error messages * [EC-317] feat: add menu bar item * [EC-317] feat: update form to support typed reactive forms * [EC-317] chore: update translation text after design review * [EC-317] feat: move deletion logic to service * [EC-317] refactor: update web deletion * [EC-317] feat: disable submit if secret is empty * [EC-317] fix: handle errors in components as well * [EC-317] fix: use abstraction as interface * [EC-317] refactor: extract deleteAccount from api service * [EC-317] fix: typo in translations * [EC-317] chore: rename to accountApiService
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
||||
|
||||
export abstract class AccountApiService {
|
||||
abstract deleteAccount(request: SecretVerificationRequest): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Verification } from "../../types/verification";
|
||||
|
||||
export abstract class AccountService {
|
||||
abstract delete(verification: Verification): Promise<any>;
|
||||
}
|
||||
@@ -209,7 +209,6 @@ export abstract class ApiService {
|
||||
setPassword: (request: SetPasswordRequest) => Promise<any>;
|
||||
postSetKeyConnectorKey: (request: SetKeyConnectorKeyRequest) => Promise<any>;
|
||||
postSecurityStamp: (request: SecretVerificationRequest) => Promise<any>;
|
||||
deleteAccount: (request: SecretVerificationRequest) => Promise<any>;
|
||||
getAccountRevisionDate: () => Promise<number>;
|
||||
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
|
||||
postRegister: (request: RegisterRequest) => Promise<any>;
|
||||
|
||||
11
libs/common/src/services/account/account-api.service.ts
Normal file
11
libs/common/src/services/account/account-api.service.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { AccountApiService as AccountApiServiceAbstraction } from "@bitwarden/common/abstractions/account/account-api.service.abstraction";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
||||
|
||||
export class AccountApiService implements AccountApiServiceAbstraction {
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
deleteAccount(request: SecretVerificationRequest): Promise<void> {
|
||||
return this.apiService.send("DELETE", "/accounts", request, true, false);
|
||||
}
|
||||
}
|
||||
27
libs/common/src/services/account/account.service.ts
Normal file
27
libs/common/src/services/account/account.service.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { AccountApiService } from "@bitwarden/common/abstractions/account/account-api.service.abstraction";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
||||
|
||||
import { AccountService as AccountServiceAbstraction } from "../../abstractions/account/account.service.abstraction";
|
||||
import { Verification } from "../../types/verification";
|
||||
|
||||
export class AccountService implements AccountServiceAbstraction {
|
||||
constructor(
|
||||
private accountApiService: AccountApiService,
|
||||
private userVerificationService: UserVerificationService,
|
||||
private messagingService: MessagingService,
|
||||
private logService: LogService
|
||||
) {}
|
||||
|
||||
async delete(verification: Verification): Promise<any> {
|
||||
try {
|
||||
const verificationRequest = await this.userVerificationService.buildRequest(verification);
|
||||
await this.accountApiService.deleteAccount(verificationRequest);
|
||||
this.messagingService.send("logout");
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,10 +350,6 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return this.send("POST", "/accounts/security-stamp", request, true, false);
|
||||
}
|
||||
|
||||
deleteAccount(request: SecretVerificationRequest): Promise<any> {
|
||||
return this.send("DELETE", "/accounts", request, true, false);
|
||||
}
|
||||
|
||||
async getAccountRevisionDate(): Promise<number> {
|
||||
const r = await this.send("GET", "/accounts/revision-date", null, true, true);
|
||||
return r as number;
|
||||
|
||||
Reference in New Issue
Block a user