Skip to content

Commit

Permalink
fix: Correctly logout OAuth client on logout notification
Browse files Browse the repository at this point in the history
When doing a logout we wan't the extension to also logout the Cozy's
Oauth client

This was done from the `runtime.background.ts` file so the action is
done when the user clicks on the Settings logout button

But this is not the only scenario that can produce a logout

This is the case when the user changes their password from
cozy-settings. In that scenario, the cozy-stack will send a `logout`
notification to the Bitwarden's realtime stream, and so the extension
will react by doing a logout

To have the OAuth logout on both scenario we want to move the related
code into `main.background.ts`
  • Loading branch information
Ldoppea committed Apr 22, 2024
1 parent 841a5f9 commit 79e6d19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions apps/browser/src/background/main.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,11 @@ export default class MainBackground {
}
//*/

// Cozy customization, logout OAuth client
//*
await this.cozyClientService.logout();
//*/

await Promise.all([
this.syncService.setLastSync(new Date(0), userId),
this.cryptoService.clearKeys(userId),
Expand Down
1 change: 0 additions & 1 deletion apps/browser/src/background/runtime.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export default class RuntimeBackground {
break;
case "logout":
// 1- logout
await this.cozyClientService.logout();
await this.main.logout(msg.expired, msg.userId);
// 2- ask all frames of all tabs to activate login-in-page-menu
for (const tab of await BrowserApi.getAllTabs()) {
Expand Down

0 comments on commit 79e6d19

Please sign in to comment.