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