Fixed login bug (#882)

This commit is contained in:
Shannon Draeker
2024-01-30 17:24:00 -07:00
committed by Álison Fernandes
parent 95b4aaf605
commit cf8f2ff7fa
27 changed files with 8 additions and 116 deletions

View File

@@ -256,18 +256,13 @@ class AuthRepositoryImpl(
authDiskSource.currentUserPoliciesListFlow
.onEach { policies ->
val userId = activeUserId ?: return@onEach
if (passwordPassesPolicies(policies)) {
vaultRepository.completeUnlock(userId = userId)
storeUserResetPasswordReason(
userId = userId,
reason = null,
)
} else {
storeUserResetPasswordReason(
userId = userId,
reason = ForcePasswordResetReason.WEAK_MASTER_PASSWORD_ON_LOGIN,
)
}
storeUserResetPasswordReason(
userId = userId,
reason = ForcePasswordResetReason.WEAK_MASTER_PASSWORD_ON_LOGIN
.takeIf {
!passwordPassesPolicies(policies)
},
)
}
.launchIn(unconfinedScope)
}
@@ -711,9 +706,6 @@ class AuthRepositoryImpl(
)
}
// Complete the login flow.
vaultRepository.completeUnlock(userId = activeAccount.profile.userId)
// Return the success.
ResetPasswordResult.Success
},

View File

@@ -40,8 +40,6 @@ data class UserState(
* @property isLoggedIn `true` if the account is logged in, or `false` if it requires additional
* authentication to view their vault.
* @property isVaultUnlocked Whether or not the user's vault is currently unlocked.
* @property isVaultPendingUnlock Whether or not the user's vault is currently pending being
* unlocked, such as when the password policy has not completed verification yet.
* @property needsPasswordReset If the user needs to reset their password.
* @property organizations List of [Organization]s the user is associated with, if any.
* @property isBiometricsEnabled Indicates that the biometrics mechanism for unlocking the
@@ -57,7 +55,6 @@ data class UserState(
val isPremium: Boolean,
val isLoggedIn: Boolean,
val isVaultUnlocked: Boolean,
val isVaultPendingUnlock: Boolean,
val needsPasswordReset: Boolean,
val organizations: List<Organization>,
val isBiometricsEnabled: Boolean,

View File

@@ -72,8 +72,6 @@ fun UserStateJson.toUserState(
isLoggedIn = accountJson.isLoggedIn,
isVaultUnlocked = vaultState.statusFor(userId) ==
VaultUnlockData.Status.UNLOCKED,
isVaultPendingUnlock = vaultState.statusFor(userId) ==
VaultUnlockData.Status.PENDING,
needsPasswordReset = accountJson.profile.forcePasswordResetReason != null,
organizations = userOrganizationsList
.find { it.userId == userId }

View File

@@ -30,12 +30,6 @@ interface VaultLockManager {
*/
fun lockVault(userId: String)
/**
* Complete the unlock flow for a given [userId], moving their pendingUnlock status
* to a full unlock.
*/
fun completeUnlock(userId: String)
/**
* Locks the vault for the current user if currently unlocked.
*/

View File

@@ -92,10 +92,6 @@ class VaultLockManagerImpl(
setVaultToLocked(userId = userId)
}
override fun completeUnlock(userId: String) {
setVaultToUnlocked(userId = userId)
}
override fun lockVaultForCurrentUser() {
activeUserId?.let {
lockVault(it)
@@ -168,7 +164,7 @@ class VaultLockManagerImpl(
.also {
if (it is VaultUnlockResult.Success) {
clearInvalidUnlockCount(userId = userId)
setVaultToPendingUnlocked(userId = userId)
setVaultToUnlocked(userId = userId)
} else {
incrementInvalidUnlockCount(userId = userId)
}
@@ -214,12 +210,6 @@ class VaultLockManagerImpl(
storeUserAutoUnlockKeyIfNecessary(userId = userId)
}
private fun setVaultToPendingUnlocked(userId: String) {
mutableVaultUnlockDataStateFlow.update {
it.update(userId, VaultUnlockData.Status.PENDING)
}
}
private fun setVaultToLocked(userId: String) {
vaultSdkSource.clearCrypto(userId = userId)
mutableVaultUnlockDataStateFlow.update {

View File

@@ -14,7 +14,6 @@ data class VaultUnlockData(
* The lock status of a user's vault.
*/
enum class Status {
PENDING,
UNLOCKED,
UNLOCKING,
}

View File

@@ -63,7 +63,6 @@ class RootNavViewModel @Inject constructor(
userState == null ||
!userState.activeAccount.isLoggedIn ||
userState.activeAccount.isVaultPendingUnlock ||
userState.hasPendingAccountAddition -> RootNavState.Auth
userState.activeAccount.isVaultUnlocked -> {