From 12c72b28338c5b8cfde74f6ce7b1d98c21ca082a Mon Sep 17 00:00:00 2001 From: Jake Fink Date: Fri, 27 Oct 2023 12:19:41 -0400 Subject: [PATCH] migrate old enc key (#2732) --- src/Core/Services/CryptoService.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Core/Services/CryptoService.cs b/src/Core/Services/CryptoService.cs index 15f8d893c..7388f8e9a 100644 --- a/src/Core/Services/CryptoService.cs +++ b/src/Core/Services/CryptoService.cs @@ -1088,6 +1088,12 @@ namespace Bit.Core.Services { await _stateService.SetUserKeyBiometricUnlockAsync(userKey, userId); } + // Clear old enc key only if we don't need to still migrate PIN + if (await _stateService.GetPinProtectedAsync() == null + && await _stateService.GetPinProtectedKeyAsync() == null) + { + await _stateService.SetEncKeyEncryptedAsync(null, userId); + } await _stateService.SetKeyEncryptedAsync(null, userId); // Set encrypted user key just in case the user locks without syncing