From a78997771f63244af41a95e8a35833d60133bf0a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 3 Jun 2019 14:21:56 -0400 Subject: [PATCH] only set pin when needed. sync after migration --- src/App/App.xaml.cs | 1 + src/App/Migration/MigrationHelpers.cs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index e6f2e0b85..16ca60b6b 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -124,6 +124,7 @@ namespace Bit.App else if(message.Command == "migrated") { await Task.Delay(1000); + SyncIfNeeded(); await SetMainPageAsync(); } }); diff --git a/src/App/Migration/MigrationHelpers.cs b/src/App/Migration/MigrationHelpers.cs index abd9c5f06..8d39e24c4 100644 --- a/src/App/Migration/MigrationHelpers.cs +++ b/src/App/Migration/MigrationHelpers.cs @@ -118,8 +118,8 @@ namespace Bit.App.Migration await storageService.SaveAsync("rememberedEmail", settingsShim.GetValueOrDefault("other:lastLoginEmail", null)); Log("Migrating 6.11"); - await storageService.SaveAsync(Constants.FingerprintUnlockKey, - settingsShim.GetValueOrDefault("setting:fingerprintUnlockOn", false)); + var oldFingerprint = settingsShim.GetValueOrDefault("setting:fingerprintUnlockOn", false); + await storageService.SaveAsync(Constants.FingerprintUnlockKey, oldFingerprint); Log("Migrating 7"); await environmentService.SetUrlsAsync(new Core.Models.Data.EnvironmentUrlData @@ -163,9 +163,12 @@ namespace Bit.App.Migration // Save pin - var pinKey = await cryptoService.MakePinKeyAysnc(oldPin, oldEmail, oldKdf, oldKdfIterations); - var pinProtectedKey = await cryptoService.EncryptAsync(oldKeyBytes, pinKey); - await storageService.SaveAsync(Constants.PinProtectedKey, pinProtectedKey.EncryptedString); + if(!string.IsNullOrWhiteSpace(oldPin) && !oldFingerprint) + { + var pinKey = await cryptoService.MakePinKeyAysnc(oldPin, oldEmail, oldKdf, oldKdfIterations); + var pinProtectedKey = await cryptoService.EncryptAsync(oldKeyBytes, pinKey); + await storageService.SaveAsync(Constants.PinProtectedKey, pinProtectedKey.EncryptedString); + } // Save new authed data