mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-26 17:08:33 +01:00
pass userId when logging out and add error handling if one isn't found in background (#8946)
This commit is contained in:
parent
5dc200577c
commit
6ae086f89a
@ -1,4 +1,4 @@
|
||||
import { Subject, firstValueFrom, merge } from "rxjs";
|
||||
import { Subject, firstValueFrom, merge, timeout } from "rxjs";
|
||||
|
||||
import {
|
||||
PinCryptoServiceAbstraction,
|
||||
@ -1196,7 +1196,18 @@ export default class MainBackground {
|
||||
}
|
||||
|
||||
async logout(expired: boolean, userId?: UserId) {
|
||||
userId ??= (await firstValueFrom(this.accountService.activeAccount$))?.id;
|
||||
userId ??= (
|
||||
await firstValueFrom(
|
||||
this.accountService.activeAccount$.pipe(
|
||||
timeout({
|
||||
first: 2000,
|
||||
with: () => {
|
||||
throw new Error("No active account found to logout");
|
||||
},
|
||||
}),
|
||||
),
|
||||
)
|
||||
)?.id;
|
||||
|
||||
await this.eventUploadService.uploadEvents(userId as UserId);
|
||||
|
||||
|
@ -21,6 +21,7 @@ import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vaul
|
||||
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||
import { DeviceType } from "@bitwarden/common/enums";
|
||||
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
||||
@ -86,6 +87,7 @@ export class SettingsComponent implements OnInit {
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private accountService: AccountService,
|
||||
private policyService: PolicyService,
|
||||
private formBuilder: FormBuilder,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
@ -434,8 +436,9 @@ export class SettingsComponent implements OnInit {
|
||||
type: "info",
|
||||
});
|
||||
|
||||
const userId = (await firstValueFrom(this.accountService.activeAccount$))?.id;
|
||||
if (confirmed) {
|
||||
this.messagingService.send("logout");
|
||||
this.messagingService.send("logout", { userId: userId });
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user