mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
support old key on password unlock
This commit is contained in:
parent
ddd521cd4b
commit
d1646e5aca
1 changed files with 12 additions and 0 deletions
|
@ -21,6 +21,7 @@ namespace Bit.App.Pages
|
|||
private readonly IStorageService _storageService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IMessagingService _messagingService;
|
||||
private readonly IStorageService _secureStorageService;
|
||||
|
||||
private bool _hasKey;
|
||||
private string _email;
|
||||
|
@ -42,6 +43,7 @@ namespace Bit.App.Pages
|
|||
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
_userService = ServiceContainer.Resolve<IUserService>("userService");
|
||||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
_secureStorageService = ServiceContainer.Resolve<IStorageService>("secureStorageService");
|
||||
|
||||
PageTitle = AppResources.VerifyMasterPassword;
|
||||
TogglePasswordCommand = new Command(TogglePassword);
|
||||
|
@ -194,6 +196,16 @@ namespace Bit.App.Pages
|
|||
var key = await _cryptoService.MakeKeyAsync(MasterPassword, _email, kdf, kdfIterations);
|
||||
var keyHash = await _cryptoService.HashPasswordAsync(MasterPassword, key);
|
||||
var storedKeyHash = await _cryptoService.GetKeyHashAsync();
|
||||
if(storedKeyHash == null)
|
||||
{
|
||||
var oldKey = await _secureStorageService.GetAsync<string>("oldKey");
|
||||
if(key.KeyB64 == oldKey)
|
||||
{
|
||||
await _secureStorageService.RemoveAsync("oldKey");
|
||||
await _cryptoService.SetKeyHashAsync(keyHash);
|
||||
storedKeyHash = keyHash;
|
||||
}
|
||||
}
|
||||
if(storedKeyHash != null && keyHash != null && storedKeyHash == keyHash)
|
||||
{
|
||||
MasterPassword = string.Empty;
|
||||
|
|
Loading…
Reference in a new issue