mirror of
https://github.com/bitwarden/android.git
synced 2026-06-07 14:57:41 -05:00
Add storage for invalid lock attempts (#637)
This commit is contained in:
committed by
Álison Fernandes
parent
c428a57ca8
commit
6220670ce3
@@ -57,6 +57,19 @@ interface AuthDiskSource {
|
||||
lastActiveTimeMillis: Long?,
|
||||
)
|
||||
|
||||
/**
|
||||
* Retrieves the number of consecutive invalid lock attempts for the given [userId].
|
||||
*/
|
||||
fun getInvalidUnlockAttempts(userId: String): Int?
|
||||
|
||||
/**
|
||||
* Stores the number of consecutive invalid lock attempts for the given [userId].
|
||||
*/
|
||||
fun storeInvalidUnlockAttempts(
|
||||
userId: String,
|
||||
invalidUnlockAttempts: Int?,
|
||||
)
|
||||
|
||||
/**
|
||||
* Retrieves a user key using a [userId].
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,7 @@ private const val UNIQUE_APP_ID_KEY = "$BASE_KEY:appId"
|
||||
private const val REMEMBERED_EMAIL_ADDRESS_KEY = "$BASE_KEY:rememberedEmail"
|
||||
private const val STATE_KEY = "$BASE_KEY:state"
|
||||
private const val LAST_ACTIVE_TIME_KEY = "$BASE_KEY:lastActiveTime"
|
||||
private const val INVALID_UNLOCK_ATTEMPTS_KEY = "$BASE_KEY:invalidUnlockAttempts"
|
||||
private const val MASTER_KEY_ENCRYPTION_USER_KEY = "$BASE_KEY:masterKeyEncryptedUserKey"
|
||||
private const val MASTER_KEY_ENCRYPTION_PRIVATE_KEY = "$BASE_KEY:encPrivateKey"
|
||||
private const val PIN_PROTECTED_USER_KEY_KEY = "$BASE_KEY:pinKeyEncryptedUserKey"
|
||||
@@ -74,6 +75,7 @@ class AuthDiskSourceImpl(
|
||||
|
||||
override fun clearData(userId: String) {
|
||||
storeLastActiveTimeMillis(userId = userId, lastActiveTimeMillis = null)
|
||||
storeInvalidUnlockAttempts(userId = userId, invalidUnlockAttempts = null)
|
||||
storeUserKey(userId = userId, userKey = null)
|
||||
storeUserAutoUnlockKey(userId = userId, userAutoUnlockKey = null)
|
||||
storePinProtectedUserKey(userId = userId, pinProtectedUserKey = null)
|
||||
@@ -96,6 +98,19 @@ class AuthDiskSourceImpl(
|
||||
)
|
||||
}
|
||||
|
||||
override fun getInvalidUnlockAttempts(userId: String): Int? =
|
||||
getInt(key = "${INVALID_UNLOCK_ATTEMPTS_KEY}_$userId")
|
||||
|
||||
override fun storeInvalidUnlockAttempts(
|
||||
userId: String,
|
||||
invalidUnlockAttempts: Int?,
|
||||
) {
|
||||
putInt(
|
||||
key = "${INVALID_UNLOCK_ATTEMPTS_KEY}_$userId",
|
||||
value = invalidUnlockAttempts,
|
||||
)
|
||||
}
|
||||
|
||||
override fun getUserKey(userId: String): String? =
|
||||
getString(key = "${MASTER_KEY_ENCRYPTION_USER_KEY}_$userId")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user