From dd2cd0d9df5d5f749c2709bd0ef2b9c610fdf251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Bispo?= Date: Mon, 24 Jul 2023 09:39:42 +0100 Subject: [PATCH] [PM-2297] code format --- src/Core/Services/AuthService.cs | 14 ++++++-------- src/Core/Services/DeviceTrustCryptoService.cs | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Core/Services/AuthService.cs b/src/Core/Services/AuthService.cs index 1af112db2..d05c081a7 100644 --- a/src/Core/Services/AuthService.cs +++ b/src/Core/Services/AuthService.cs @@ -490,7 +490,7 @@ namespace Bit.Core.Services await _cryptoService.SetMasterKeyEncryptedUserKeyAsync(tokenResponse.Key); var decryptOptions = await _stateService.GetAccountDecryptionOptions(); - if (await _deviceTrustCryptoService.IsDeviceTrustedAsync() && decryptOptions?.TrustedDeviceOption != null) + if (decryptOptions?.TrustedDeviceOption != null) { var key = await _deviceTrustCryptoService.DecryptUserKeyWithDeviceKeyAsync(decryptOptions?.TrustedDeviceOption.EncryptedPrivateKey, decryptOptions?.TrustedDeviceOption.EncryptedUserKey); if (key != null) @@ -498,14 +498,12 @@ namespace Bit.Core.Services await _cryptoService.SetUserKeyAsync(key); } } - else if (!string.IsNullOrEmpty(tokenResponse.KeyConnectorUrl) || !string.IsNullOrEmpty(decryptOptions?.KeyConnectorOption?.KeyConnectorUrl)) + else if (masterKey != null && + (!string.IsNullOrEmpty(tokenResponse.KeyConnectorUrl) || !string.IsNullOrEmpty(decryptOptions?.KeyConnectorOption?.KeyConnectorUrl))) { - if (masterKey != null) - { - await _cryptoService.SetMasterKeyAsync(masterKey); - var userKey = await _cryptoService.DecryptUserKeyWithMasterKeyAsync(masterKey); - await _cryptoService.SetUserKeyAsync(userKey); - } + await _cryptoService.SetMasterKeyAsync(masterKey); + var userKey = await _cryptoService.DecryptUserKeyWithMasterKeyAsync(masterKey); + await _cryptoService.SetUserKeyAsync(userKey); } // User doesn't have a key pair yet (old account), let's generate one for them. diff --git a/src/Core/Services/DeviceTrustCryptoService.cs b/src/Core/Services/DeviceTrustCryptoService.cs index c56df81b4..93ccb905e 100644 --- a/src/Core/Services/DeviceTrustCryptoService.cs +++ b/src/Core/Services/DeviceTrustCryptoService.cs @@ -113,8 +113,8 @@ namespace Bit.Core.Services if (existingDeviceKey == null) { - // User doesn't have a device key anymore so device is untrusted - return null; + // User doesn't have a device key anymore so device is untrusted + return null; } // Attempt to decrypt encryptedDevicePrivateKey with device key