From 0f451fd4b902286340d895277c3801856e1850ed Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 10 Aug 2019 00:19:01 -0400 Subject: [PATCH] set FingerprintUnlockKey before setKey --- src/App/Migration/MigrationHelpers.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/App/Migration/MigrationHelpers.cs b/src/App/Migration/MigrationHelpers.cs index 28f19f276..af3425c63 100644 --- a/src/App/Migration/MigrationHelpers.cs +++ b/src/App/Migration/MigrationHelpers.cs @@ -160,6 +160,12 @@ namespace Bit.App.Migration await tokenService.SetTokensAsync(oldToken, oldRefreshToken); await userService.SetInformationAsync(oldUserId, oldEmail, oldKdf, oldKdfIterations); + // Save fingerprint + if(oldFingerprint) + { + await storageService.SaveAsync(Constants.FingerprintUnlockKey, true); + } + var newKey = new Core.Models.Domain.SymmetricCryptoKey(oldKey.Key); await cryptoService.SetKeyAsync(newKey); // Key hash is unavailable in old version, store old key until we can move it to key hash @@ -167,13 +173,8 @@ namespace Bit.App.Migration await cryptoService.SetEncKeyAsync(oldEncKey); await cryptoService.SetEncPrivateKeyAsync(oldEncPrivateKey); - // Save fingerprint/pin - - if(oldFingerprint) - { - await storageService.SaveAsync(Constants.FingerprintUnlockKey, true); - } - else if(!string.IsNullOrWhiteSpace(oldPin)) + // Save pin + if(!oldFingerprint && !string.IsNullOrWhiteSpace(oldPin)) { var pinKey = await cryptoService.MakePinKeyAysnc(oldPin, oldEmail, oldKdf, oldKdfIterations); var pinProtectedKey = await cryptoService.EncryptAsync(oldKeyBytes, pinKey);