mirror of
https://github.com/bitwarden/android.git
synced 2026-06-06 22:42:58 -05:00
Fixed login bug (#882)
This commit is contained in:
committed by
Álison Fernandes
parent
95b4aaf605
commit
cf8f2ff7fa
@@ -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
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -14,7 +14,6 @@ data class VaultUnlockData(
|
||||
* The lock status of a user's vault.
|
||||
*/
|
||||
enum class Status {
|
||||
PENDING,
|
||||
UNLOCKED,
|
||||
UNLOCKING,
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ class RootNavViewModel @Inject constructor(
|
||||
|
||||
userState == null ||
|
||||
!userState.activeAccount.isLoggedIn ||
|
||||
userState.activeAccount.isVaultPendingUnlock ||
|
||||
userState.hasPendingAccountAddition -> RootNavState.Auth
|
||||
|
||||
userState.activeAccount.isVaultUnlocked -> {
|
||||
|
||||
Reference in New Issue
Block a user