diff --git a/src/Core/Services/DeviceTrustCryptoService.cs b/src/Core/Services/DeviceTrustCryptoService.cs index 0d9b81aa9..93ccb905e 100644 --- a/src/Core/Services/DeviceTrustCryptoService.cs +++ b/src/Core/Services/DeviceTrustCryptoService.cs @@ -33,14 +33,12 @@ namespace Bit.Core.Services public async Task GetDeviceKeyAsync() { - var activeUserId = await _stateService.GetActiveUserIdAsync(); - return await _stateService.GetDeviceKeyAsync(activeUserId); + return await _stateService.GetDeviceKeyAsync(); } private async Task SetDeviceKeyAsync(SymmetricCryptoKey deviceKey) { - var activeUserId = await _stateService.GetActiveUserIdAsync(); - await _stateService.SetDeviceKeyAsync(deviceKey, activeUserId); + await _stateService.SetDeviceKeyAsync(deviceKey); } public async Task TrustDeviceAsync() diff --git a/src/Core/Services/StateService.cs b/src/Core/Services/StateService.cs index 49a069ddf..480bacaaa 100644 --- a/src/Core/Services/StateService.cs +++ b/src/Core/Services/StateService.cs @@ -515,7 +515,9 @@ namespace Bit.Core.Services public async Task GetDeviceKeyAsync(string userId = null) { - var deviceKeyB64 = await _storageMediatorService.GetAsync(Constants.DeviceKeyKey(userId), true); + var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, + await GetDefaultStorageOptionsAsync()); + var deviceKeyB64 = await _storageMediatorService.GetAsync(Constants.DeviceKeyKey(reconciledOptions.UserId), true); if (string.IsNullOrEmpty(deviceKeyB64)) { return null; @@ -525,7 +527,9 @@ namespace Bit.Core.Services public async Task SetDeviceKeyAsync(SymmetricCryptoKey value, string userId = null) { - await _storageMediatorService.SaveAsync(Constants.DeviceKeyKey(userId), value.KeyB64, true); + var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, + await GetDefaultStorageOptionsAsync()); + await _storageMediatorService.SaveAsync(Constants.DeviceKeyKey(reconciledOptions.UserId), value.KeyB64, true); } public async Task> GetAutofillBlacklistedUrisAsync(string userId = null)