1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-11 05:43:30 +00:00

Get UserKey from bio state on unlock

This commit is contained in:
Jacob Fink
2023-08-04 16:34:27 -04:00
parent b620a9c09f
commit 2522bbc60f
2 changed files with 17 additions and 6 deletions

View File

@@ -297,7 +297,7 @@ namespace Bit.App.Pages
{ {
Pin = string.Empty; Pin = string.Empty;
await AppHelpers.ResetInvalidUnlockAttemptsAsync(); await AppHelpers.ResetInvalidUnlockAttemptsAsync();
await SetKeyAndContinueAsync(userKey); await SetUserKeyAndContinueAsync(userKey);
} }
} }
catch catch
@@ -364,7 +364,7 @@ namespace Bit.App.Pages
var userKey = await _cryptoService.DecryptUserKeyWithMasterKeyAsync(masterKey); var userKey = await _cryptoService.DecryptUserKeyWithMasterKeyAsync(masterKey);
await _cryptoService.SetMasterKeyAsync(masterKey); await _cryptoService.SetMasterKeyAsync(masterKey);
await SetKeyAndContinueAsync(userKey); await SetUserKeyAndContinueAsync(userKey);
// Re-enable biometrics // Re-enable biometrics
if (BiometricEnabled & !BiometricIntegrityValid) if (BiometricEnabled & !BiometricIntegrityValid)
@@ -462,11 +462,12 @@ namespace Bit.App.Pages
await _stateService.SetBiometricLockedAsync(!success); await _stateService.SetBiometricLockedAsync(!success);
if (success) if (success)
{ {
await DoContinueAsync(); var userKey = await _stateService.GetUserKeyBiometricUnlockAsync();
await SetUserKeyAndContinueAsync(userKey);
} }
} }
private async Task SetKeyAndContinueAsync(UserKey key) private async Task SetUserKeyAndContinueAsync(UserKey key)
{ {
var hasKey = await _cryptoService.HasUserKeyAsync(); var hasKey = await _cryptoService.HasUserKeyAsync();
if (!hasKey) if (!hasKey)

View File

@@ -670,7 +670,7 @@ namespace Bit.Core.Services
private async Task StoreAdditionalKeysAsync(UserKey userKey, string userId = null) private async Task StoreAdditionalKeysAsync(UserKey userKey, string userId = null)
{ {
// Refresh, set, or clear the pin key // Set, refresh, or clear the pin key
if (await _stateService.GetProtectedPinAsync(userId) != null) if (await _stateService.GetProtectedPinAsync(userId) != null)
{ {
await UpdatePinKeyAsync(userKey, userId); await UpdatePinKeyAsync(userKey, userId);
@@ -681,7 +681,7 @@ namespace Bit.Core.Services
await _stateService.SetPinKeyEncryptedUserKeyEphemeralAsync(null, userId); await _stateService.SetPinKeyEncryptedUserKeyEphemeralAsync(null, userId);
} }
// Refresh, set, or clear the auto key // Set, refresh, or clear the auto unlock key
if (await _stateService.GetVaultTimeoutAsync(userId) == null) if (await _stateService.GetVaultTimeoutAsync(userId) == null)
{ {
await _stateService.SetUserKeyAutoUnlockAsync(userKey, userId); await _stateService.SetUserKeyAutoUnlockAsync(userKey, userId);
@@ -690,6 +690,16 @@ namespace Bit.Core.Services
{ {
await _stateService.SetUserKeyAutoUnlockAsync(null, userId); await _stateService.SetUserKeyAutoUnlockAsync(null, userId);
} }
// Set, refresh, or clear the biometric unlock key
if ((await _stateService.GetBiometricUnlockAsync(userId)).GetValueOrDefault())
{
await _stateService.SetUserKeyBiometricUnlockAsync(userKey, userId);
}
else
{
await _stateService.SetUserKeyBiometricUnlockAsync(null, userId);
}
} }
private async Task UpdatePinKeyAsync(UserKey userKey, string userId = null) private async Task UpdatePinKeyAsync(UserKey userKey, string userId = null)