1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 05:13:29 +00:00

[PM-3050] Add sync on unlock, logout when account is deleted (#9288)

* Add sync on unlock, logout when account is deleted

* Update libs/common/src/vault/services/sync/sync.service.ts

Co-authored-by: SmithThe4th <gsmith@bitwarden.com>

* Fix failing unit tests

* Fix incorrect merge

---------

Co-authored-by: SmithThe4th <gsmith@bitwarden.com>
This commit is contained in:
Bernd Schoolmann
2024-05-30 11:10:03 +02:00
committed by GitHub
parent 6d0ef65094
commit f6942dde74
5 changed files with 21 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ import { HashPurpose, KeySuffixOptions } from "@bitwarden/common/platform/enums"
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
import { UserId } from "@bitwarden/common/types/guid";
import { UserKey } from "@bitwarden/common/types/key";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { DialogService } from "@bitwarden/components";
@Directive()
@@ -85,6 +86,7 @@ export class LockComponent implements OnInit, OnDestroy {
protected accountService: AccountService,
protected authService: AuthService,
protected kdfConfigService: KdfConfigService,
protected syncService: SyncService,
) {}
async ngOnInit() {
@@ -318,6 +320,9 @@ export class LockComponent implements OnInit, OnDestroy {
}
}
// Vault can be de-synced since notifications get ignored while locked. Need to check whether sync is required using the sync service.
await this.syncService.fullSync(false);
if (this.onSuccessfulSubmit != null) {
await this.onSuccessfulSubmit();
} else if (this.router != null) {

View File

@@ -145,6 +145,11 @@ export class SyncService extends CoreSyncService {
}
const response = await this.apiService.getAccountRevisionDate();
if (response < 0 && this.logoutCallback) {
// Account was deleted, log out now
await this.logoutCallback(false);
}
if (new Date(response) <= lastSync) {
return false;
}