1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-10 21:33:36 +00:00

[PM-2297] PR fixes

This commit is contained in:
André Bispo
2023-07-27 12:27:08 +01:00
parent 9b7dc7210f
commit 8ff79d0e86
3 changed files with 7 additions and 9 deletions

View File

@@ -218,7 +218,7 @@ namespace Bit.App.Pages
{ {
UpdateTempPasswordAction?.Invoke(); UpdateTempPasswordAction?.Invoke();
} }
else if (decryptOptions.TrustedDeviceOption != null) else if (decryptOptions?.TrustedDeviceOption != null)
{ {
// If user doesn't have a MP, but has reset password permission, they must set a MP // If user doesn't have a MP, but has reset password permission, they must set a MP
if (!decryptOptions.HasMasterPassword && if (!decryptOptions.HasMasterPassword &&
@@ -232,7 +232,7 @@ namespace Bit.App.Pages
} }
else if (await _deviceTrustCryptoService.IsDeviceTrustedAsync()) else if (await _deviceTrustCryptoService.IsDeviceTrustedAsync())
{ {
var task = Task.Run(async () => await _syncService.FullSyncAsync(true)); _syncService.FullSyncAsync(true).FireAndForget();
SsoAuthSuccessAction?.Invoke(); SsoAuthSuccessAction?.Invoke();
} }
else else
@@ -242,7 +242,7 @@ namespace Bit.App.Pages
} }
else else
{ {
var task = Task.Run(async () => await _syncService.FullSyncAsync(true)); _syncService.FullSyncAsync(true).FireAndForget();
SsoAuthSuccessAction?.Invoke(); SsoAuthSuccessAction?.Invoke();
} }
} }

View File

@@ -487,7 +487,7 @@ namespace Bit.Core.Services
if (decryptOptions?.TrustedDeviceOption != null) if (decryptOptions?.TrustedDeviceOption != null)
{ {
var key = await _deviceTrustCryptoService.DecryptUserKeyWithDeviceKeyAsync(decryptOptions?.TrustedDeviceOption.EncryptedPrivateKey, decryptOptions?.TrustedDeviceOption.EncryptedUserKey); var key = await _deviceTrustCryptoService.DecryptUserKeyWithDeviceKeyAsync(decryptOptions.TrustedDeviceOption.EncryptedPrivateKey, decryptOptions.TrustedDeviceOption.EncryptedUserKey);
if (key != null) if (key != null)
{ {
await _cryptoService.SetUserKeyAsync(key); await _cryptoService.SetUserKeyAsync(key);

View File

@@ -108,9 +108,7 @@ namespace Bit.Core.Services
public async Task<UserKey> DecryptUserKeyWithDeviceKeyAsync(string encryptedDevicePrivateKey, string encryptedUserKey) public async Task<UserKey> DecryptUserKeyWithDeviceKeyAsync(string encryptedDevicePrivateKey, string encryptedUserKey)
{ {
// Get device key
var existingDeviceKey = await GetDeviceKeyAsync(); var existingDeviceKey = await GetDeviceKeyAsync();
if (existingDeviceKey == null) if (existingDeviceKey == null)
{ {
// User doesn't have a device key anymore so device is untrusted // User doesn't have a device key anymore so device is untrusted
@@ -118,14 +116,14 @@ namespace Bit.Core.Services
} }
// Attempt to decrypt encryptedDevicePrivateKey with device key // Attempt to decrypt encryptedDevicePrivateKey with device key
var devicePrivateKey = await _cryptoService.DecryptToBytesAsync( var devicePrivateKeyBytes = await _cryptoService.DecryptToBytesAsync(
new EncString(encryptedDevicePrivateKey), new EncString(encryptedDevicePrivateKey),
existingDeviceKey existingDeviceKey
); );
// Attempt to decrypt encryptedUserDataKey with devicePrivateKey // Attempt to decrypt encryptedUserDataKey with devicePrivateKey
var userKey = await _cryptoService.RsaDecryptAsync(encryptedUserKey, devicePrivateKey); var userKeyBytes = await _cryptoService.RsaDecryptAsync(encryptedUserKey, devicePrivateKeyBytes);
return new UserKey(userKey); return new UserKey(userKeyBytes);
} }
} }
} }