-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Auth/PM-19555 - Fix multi account logout on lock screens not redirecting properly #14630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JaredSnider-Bitwarden
wants to merge
21
commits into
main
Choose a base branch
from
auth/pm-19555/multi-account-logout-on-lock-screens-defect
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+313
โ203
Open
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
64efe00
PM-19555 - LogoutService - build abstraction, default, and extension โฆ
JaredSnider-Bitwarden 59421d8
PM-19555 - Lock Comp - use logoutService
JaredSnider-Bitwarden 7612123
PM-19555 - LoginDecryptionOptions - Use logout service which removed โฆ
JaredSnider-Bitwarden dfa7788
PM-19555 - AccountSwitcher logic update - (1) Use logout service + reโฆ
JaredSnider-Bitwarden 172b04a
Merge branch 'main' into auth/pm-19555/multi-account-logout-on-lock-sโฆ
JaredSnider-Bitwarden 430a8f0
PM-19555 - Extension - Acct Switcher comp - clean up TODOs
JaredSnider-Bitwarden 85fe195
PM-19555 - Add TODOs for remaining tech debt
JaredSnider-Bitwarden 2fd9387
PM-19555 - Add tests for new logout services.
JaredSnider-Bitwarden a3e84b6
PM-19555 - Extension - LoginInitiated - show acct switcher b/c user iโฆ
JaredSnider-Bitwarden 0b7fd09
PM-19555 - Add TODO to replace LogoutCallback with LogoutService
JaredSnider-Bitwarden fdf8f12
PM-19555 WIP
JaredSnider-Bitwarden dcfb958
PM-19555 - Extension App Comp - account switching to account in TDE lโฆ
JaredSnider-Bitwarden 4de0bf2
PM-19555 - Extension App Comp - add docs
JaredSnider-Bitwarden f4d5c67
PM-19555 - Extension App Comp - add early return
JaredSnider-Bitwarden 6a6326b
PM-19555 - Desktop App Comp - add handling for TDE lock case to switcโฆ
JaredSnider-Bitwarden f32942a
Merge remote-tracking branch 'origin/main' into auth/pm-19555/multi-aโฆ
JaredSnider-Bitwarden d07cc16
PM-19555 - Extension - Account Component - if account unlocked go to โฆ
JaredSnider-Bitwarden a165492
PM-19555 - Per PR feedback, clean up unnecessary nullish coalescing oโฆ
JaredSnider-Bitwarden 0c88286
Merge remote-tracking branch 'origin/main' into auth/pm-19555/multi-aโฆ
JaredSnider-Bitwarden 06ea455
Merge remote-tracking branch 'origin/main' into auth/pm-19555/multi-aโฆ
JaredSnider-Bitwarden 8181921
PM-19555 - Extension - AppComponent - fix everHadUserKey merge issue
JaredSnider-Bitwarden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
...rc/auth/popup/login-decryption-options/extension-login-decryption-options.service.spec.ts
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
...ser/src/auth/popup/login-decryption-options/extension-login-decryption-options.service.ts
This file was deleted.
Oops, something went wrong.
101 changes: 101 additions & 0 deletions
101
apps/browser/src/auth/popup/logout/extension-logout.service.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { MockProxy, mock } from "jest-mock-extended"; | ||
|
||
import { LogoutReason, LogoutService } from "@bitwarden/auth/common"; | ||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; | ||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; | ||
import { UserId } from "@bitwarden/common/types/guid"; | ||
|
||
import { AccountSwitcherService } from "../account-switching/services/account-switcher.service"; | ||
|
||
import { ExtensionLogoutService } from "./extension-logout.service"; | ||
|
||
describe("ExtensionLogoutService", () => { | ||
let logoutService: LogoutService; | ||
let messagingService: MockProxy<MessagingService>; | ||
let accountSwitcherService: MockProxy<AccountSwitcherService>; | ||
|
||
let primaryUserId: UserId; | ||
let secondaryUserId: UserId; | ||
let logoutReason: LogoutReason; | ||
|
||
beforeEach(() => { | ||
primaryUserId = "1" as UserId; | ||
secondaryUserId = "2" as UserId; | ||
logoutReason = "vaultTimeout"; | ||
|
||
messagingService = mock<MessagingService>(); | ||
accountSwitcherService = mock<AccountSwitcherService>(); | ||
logoutService = new ExtensionLogoutService(messagingService, accountSwitcherService); | ||
}); | ||
|
||
it("instantiates", () => { | ||
expect(logoutService).not.toBeFalsy(); | ||
}); | ||
|
||
describe("logout", () => { | ||
describe("No new active user", () => { | ||
beforeEach(() => { | ||
accountSwitcherService.listenForSwitchAccountFinish.mockResolvedValue(null); | ||
}); | ||
|
||
it("sends logout message without a logout reason when not provided", async () => { | ||
const result = await logoutService.logout(primaryUserId); | ||
|
||
expect(accountSwitcherService.listenForSwitchAccountFinish).toHaveBeenCalledTimes(1); | ||
expect(messagingService.send).toHaveBeenCalledWith("logout", { userId: primaryUserId }); | ||
|
||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it("sends logout message with a logout reason when provided", async () => { | ||
const result = await logoutService.logout(primaryUserId, logoutReason); | ||
|
||
expect(accountSwitcherService.listenForSwitchAccountFinish).toHaveBeenCalledTimes(1); | ||
expect(messagingService.send).toHaveBeenCalledWith("logout", { | ||
userId: primaryUserId, | ||
logoutReason, | ||
}); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe("New active user", () => { | ||
const newActiveUserAuthenticationStatus = AuthenticationStatus.Unlocked; | ||
|
||
beforeEach(() => { | ||
accountSwitcherService.listenForSwitchAccountFinish.mockResolvedValue({ | ||
userId: secondaryUserId, | ||
authenticationStatus: newActiveUserAuthenticationStatus, | ||
}); | ||
}); | ||
|
||
it("sends logout message without a logout reason when not provided and returns the new active user", async () => { | ||
const result = await logoutService.logout(primaryUserId); | ||
|
||
expect(accountSwitcherService.listenForSwitchAccountFinish).toHaveBeenCalledTimes(1); | ||
|
||
expect(messagingService.send).toHaveBeenCalledWith("logout", { userId: primaryUserId }); | ||
|
||
expect(result).toEqual({ | ||
userId: secondaryUserId, | ||
authenticationStatus: newActiveUserAuthenticationStatus, | ||
}); | ||
}); | ||
|
||
it("sends logout message with a logout reason when provided and returns the new active user", async () => { | ||
const result = await logoutService.logout(primaryUserId, logoutReason); | ||
|
||
expect(accountSwitcherService.listenForSwitchAccountFinish).toHaveBeenCalledTimes(1); | ||
|
||
expect(messagingService.send).toHaveBeenCalledWith("logout", { | ||
userId: primaryUserId, | ||
logoutReason, | ||
}); | ||
expect(result).toEqual({ | ||
userId: secondaryUserId, | ||
authenticationStatus: newActiveUserAuthenticationStatus, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Product signed off on this change in behavior so next up users are left in the correct default state instead of on any screen that the first user was using.