1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-03-10 13:09:37 +01:00

[PM-6037] Fix process reload not triggering on inactive account lock/logout (#9805)

* Send loggedOut/locked events on logout/lock event

* Revert "Send loggedOut/locked events on logout/lock event"

This reverts commit 293f2d6131.

* Ensure loggedOut is sent for non-active user logouts too

* Make loggedOut accept userIds

* Add userBeingLoggedOut in desktop app component

* Await updateconnection calls
This commit is contained in:
Bernd Schoolmann 2024-09-13 18:11:05 +02:00 committed by GitHub
parent 0080fcc979
commit 54cc35e29a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 13 deletions

View File

@ -194,9 +194,9 @@ export class AppComponent implements OnInit, OnDestroy {
break; break;
case "loggedOut": case "loggedOut":
this.modalService.closeAll(); this.modalService.closeAll();
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. if (message.userId == null || message.userId === this.activeUserId) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises await this.notificationsService.updateConnection();
this.notificationsService.updateConnection(); }
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises // eslint-disable-next-line @typescript-eslint/no-floating-promises
this.updateAppMenu(); this.updateAppMenu();
@ -694,9 +694,7 @@ export class AppComponent implements OnInit, OnDestroy {
// This must come last otherwise the logout will prematurely trigger // This must come last otherwise the logout will prematurely trigger
// a process reload before all the state service user data can be cleaned up // a process reload before all the state service user data can be cleaned up
if (userBeingLoggedOut === activeUserId) { this.authService.logOut(async () => {}, userBeingLoggedOut);
this.authService.logOut(async () => {});
}
} }
private async recordActivity() { private async recordActivity() {

View File

@ -119,9 +119,12 @@ export class AppComponent implements OnDestroy, OnInit {
this.notificationsService.updateConnection(false); this.notificationsService.updateConnection(false);
break; break;
case "loggedOut": case "loggedOut":
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. if (
// eslint-disable-next-line @typescript-eslint/no-floating-promises message.userId == null ||
this.notificationsService.updateConnection(false); message.userId === (await firstValueFrom(this.accountService.activeAccount$))
) {
await this.notificationsService.updateConnection(false);
}
break; break;
case "unlocked": case "unlocked":
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
@ -311,7 +314,7 @@ export class AppComponent implements OnDestroy, OnInit {
// eslint-disable-next-line @typescript-eslint/no-floating-promises // eslint-disable-next-line @typescript-eslint/no-floating-promises
this.router.navigate(["/"]); this.router.navigate(["/"]);
} }
}); }, userId);
} }
private async recordActivity() { private async recordActivity() {

View File

@ -16,5 +16,5 @@ export abstract class AuthService {
abstract authStatusFor$(userId: UserId): Observable<AuthenticationStatus>; abstract authStatusFor$(userId: UserId): Observable<AuthenticationStatus>;
/** @deprecated use {@link activeAccountStatus$} instead */ /** @deprecated use {@link activeAccountStatus$} instead */
abstract getAuthStatus: (userId?: string) => Promise<AuthenticationStatus>; abstract getAuthStatus: (userId?: string) => Promise<AuthenticationStatus>;
abstract logOut: (callback: () => void) => void; abstract logOut: (callback: () => void, userId?: string) => void;
} }

View File

@ -93,8 +93,8 @@ export class AuthService implements AuthServiceAbstraction {
return await firstValueFrom(this.authStatusFor$(userId as UserId)); return await firstValueFrom(this.authStatusFor$(userId as UserId));
} }
logOut(callback: () => void) { logOut(callback: () => void, userId?: string): void {
callback(); callback();
this.messageSender.send("loggedOut"); this.messageSender.send("loggedOut", { userId });
} }
} }