mirror of
https://github.com/bitwarden/android.git
synced 2024-11-22 01:16:02 +03:00
PM-10899: Fix user not being logged out properly on app restart (#3822)
This commit is contained in:
parent
9db09c18cc
commit
666c165b6f
4 changed files with 16 additions and 9 deletions
|
@ -476,10 +476,15 @@ class VaultLockManagerImpl(
|
|||
}
|
||||
|
||||
else -> {
|
||||
// Only perform action for users losing "fully active" status in some way.
|
||||
when (checkTimeoutReason) {
|
||||
// Don't perform delayed actions when first starting the app
|
||||
CheckTimeoutReason.APP_RESTARTED -> Unit
|
||||
// Always preform the timeout action on app restart to ensure the user is
|
||||
// in the correct state.
|
||||
CheckTimeoutReason.APP_RESTARTED -> {
|
||||
handleTimeoutAction(
|
||||
userId = userId,
|
||||
vaultTimeoutAction = vaultTimeoutAction,
|
||||
)
|
||||
}
|
||||
|
||||
// User no longer active or engaging with the app.
|
||||
CheckTimeoutReason.APP_BACKGROUNDED,
|
||||
|
|
|
@ -63,8 +63,7 @@ class RootNavViewModel @Inject constructor(
|
|||
val specialCircumstance = action.specialCircumstance
|
||||
val updatedRootNavState = when {
|
||||
userState?.activeAccount?.trustedDevice?.isDeviceTrusted == false &&
|
||||
!userState.activeAccount.isVaultUnlocked &&
|
||||
!userState.activeAccount.hasManualUnlockMechanism -> RootNavState.TrustedDevice
|
||||
!userState.activeAccount.isVaultUnlocked -> RootNavState.TrustedDevice
|
||||
|
||||
userState?.activeAccount?.needsMasterPassword == true -> RootNavState.SetPassword
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ class VaultLockManagerTest {
|
|||
|
||||
fakeAppForegroundManager.appForegroundState = AppForegroundState.FOREGROUNDED
|
||||
|
||||
assertTrue(vaultLockManager.isVaultUnlocked(USER_ID))
|
||||
assertFalse(vaultLockManager.isVaultUnlocked(USER_ID))
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
|
@ -330,6 +330,8 @@ class VaultLockManagerTest {
|
|||
|
||||
// Start in a foregrounded state
|
||||
fakeAppForegroundManager.appForegroundState = AppForegroundState.BACKGROUNDED
|
||||
// We want to skip the first time since that is different from subsequent foregrounds
|
||||
fakeAppForegroundManager.appForegroundState = AppForegroundState.FOREGROUNDED
|
||||
|
||||
// Will be used within each loop to reset the test to a suitable initial state.
|
||||
fun resetTest(vaultTimeout: VaultTimeout) {
|
||||
|
|
|
@ -170,8 +170,9 @@ class RootNavViewModelTest : BaseViewModelTest() {
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `when the active user has an untrusted device the nav state should be TrustedDevice`() {
|
||||
fun `when the active user has an untrusted device without password the nav state should be TrustedDevice`() {
|
||||
mutableUserStateFlow.tryEmit(
|
||||
UserState(
|
||||
activeUserId = "activeUserId",
|
||||
|
@ -207,7 +208,7 @@ class RootNavViewModelTest : BaseViewModelTest() {
|
|||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `when the active user has an untrusted device with password the nav state should be VaultLocked`() {
|
||||
fun `when the active user has an untrusted device with password the nav state should be TrustedDevice`() {
|
||||
mutableUserStateFlow.tryEmit(
|
||||
UserState(
|
||||
activeUserId = "activeUserId",
|
||||
|
@ -238,7 +239,7 @@ class RootNavViewModelTest : BaseViewModelTest() {
|
|||
),
|
||||
)
|
||||
val viewModel = createViewModel()
|
||||
assertEquals(RootNavState.VaultLocked, viewModel.stateFlow.value)
|
||||
assertEquals(RootNavState.TrustedDevice, viewModel.stateFlow.value)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
|
|
Loading…
Reference in a new issue