1
0
mirror of https://github.com/bitwarden/desktop synced 2026-02-14 15:33:30 +00:00

[bug] Ensure the logout command callback can handle any user in state

This commit is contained in:
addison
2021-11-05 11:58:35 -04:00
parent ad3298838e
commit a96ac61d98
2 changed files with 21 additions and 21 deletions

View File

@@ -145,7 +145,7 @@ export class AppComponent implements OnInit {
this.router.navigate(['login']);
break;
case 'logout':
this.logOut(!!message.expired);
this.logOut(!!message.expired, message.userId);
break;
case 'lockVault':
await this.vaultTimeoutService.lock(true, message.userId);
@@ -352,34 +352,34 @@ export class AppComponent implements OnInit {
}
}
private async logOut(expired: boolean) {
await this.eventService.uploadEvents();
const userId = await this.stateService.getUserId();
private async logOut(expired: boolean, userId?: string) {
await Promise.all([
this.eventService.clearEvents(),
this.syncService.setLastSync(new Date(0)),
this.tokenService.clearToken(),
this.cryptoService.clearKeys(),
this.eventService.uploadEvents(userId),
this.syncService.setLastSync(new Date(0), userId),
this.tokenService.clearToken(userId),
this.cryptoService.clearKeys(userId),
this.settingsService.clear(userId),
this.cipherService.clear(userId),
this.folderService.clear(userId),
this.collectionService.clear(userId),
this.passwordGenerationService.clear(),
this.vaultTimeoutService.clear(),
this.passwordGenerationService.clear(userId),
this.vaultTimeoutService.clear(userId),
this.policyService.clear(userId),
await this.stateService.purge(),
this.stateService.purge({ userId: userId }),
]);
await this.stateService.setBiometricLocked(true);
this.searchService.clearIndex();
this.authService.logOut(async () => {
if (expired) {
this.toasterService.popAsync('warning', this.i18nService.t('loggedOut'),
this.i18nService.t('loginExpired'));
}
this.router.navigate(['login']);
});
if (userId == await this.stateService.getUserId()) {
this.searchService.clearIndex();
this.authService.logOut(async () => {
if (expired) {
this.toasterService.popAsync('warning', this.i18nService.t('loggedOut'),
this.i18nService.t('loginExpired'));
}
this.router.navigate(['login']);
});
}
}
private async recordActivity() {

View File

@@ -125,7 +125,7 @@ const providerService: ProviderServiceAbstraction = new ProviderService(stateSer
const policyService = new PolicyService(stateService, organizationService, apiService);
const vaultTimeoutService = new VaultTimeoutService(cipherService, folderService, collectionService,
cryptoService, platformUtilsService, messagingService, searchService, tokenService, policyService, stateService, null,
async () => messagingService.send('logout', { expired: false }));
async (userId?: string) => messagingService.send('logout', { userId: userId, expired: false }));
const syncService = new SyncService(apiService, settingsService,
folderService, cipherService, cryptoService, collectionService, messagingService, policyService, sendService, logService,
async (expired: boolean) => messagingService.send('logout', { expired: expired }), stateService, organizationService, providerService);