1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-18 09:13:15 +00:00

[PM-7877] Added loading dialog when unlocking with PIN (#3215)

* PM-7877 Added loading dialog when unlocking with PIN

* PM-7877 Added exception logging on unlock with PIN
This commit is contained in:
Federico Maccaroni
2024-05-03 14:22:46 -03:00
committed by GitHub
parent 13ca0fd4cb
commit 12385d9add

View File

@@ -285,6 +285,8 @@ namespace Bit.App.Pages
var failed = true; var failed = true;
try try
{ {
await MainThread.InvokeOnMainThreadAsync(() => _deviceActionService.ShowLoadingAsync(AppResources.Loading));
EncString userKeyPin; EncString userKeyPin;
EncString oldPinProtected; EncString oldPinProtected;
switch (_pinStatus) switch (_pinStatus)
@@ -333,21 +335,26 @@ namespace Bit.App.Pages
{ {
Pin = string.Empty; Pin = string.Empty;
await AppHelpers.ResetInvalidUnlockAttemptsAsync(); await AppHelpers.ResetInvalidUnlockAttemptsAsync();
await SetUserKeyAndContinueAsync(userKey); await SetUserKeyAndContinueAsync(userKey, shouldHandleHideLoading: true);
await Task.Delay(150); //Workaround Delay to avoid "duplicate" execution of SubmitAsync on Android when invoked from the ReturnCommand await Task.Delay(150); //Workaround Delay to avoid "duplicate" execution of SubmitAsync on Android when invoked from the ReturnCommand
} }
} }
catch (LegacyUserException) catch (LegacyUserException)
{ {
await MainThread.InvokeOnMainThreadAsync(_deviceActionService.HideLoadingAsync);
throw; throw;
} }
catch catch (Exception ex)
{ {
_logger.Exception(ex);
failed = true; failed = true;
} }
if (failed) if (failed)
{ {
var invalidUnlockAttempts = await AppHelpers.IncrementInvalidUnlockAttemptsAsync(); var invalidUnlockAttempts = await AppHelpers.IncrementInvalidUnlockAttemptsAsync();
await MainThread.InvokeOnMainThreadAsync(_deviceActionService.HideLoadingAsync);
if (invalidUnlockAttempts >= 5) if (invalidUnlockAttempts >= 5)
{ {
_messagingService.Send("logout"); _messagingService.Send("logout");
@@ -536,7 +543,7 @@ namespace Bit.App.Pages
} }
} }
private async Task SetUserKeyAndContinueAsync(UserKey key) private async Task SetUserKeyAndContinueAsync(UserKey key, bool shouldHandleHideLoading = false)
{ {
var hasKey = await _cryptoService.HasUserKeyAsync(); var hasKey = await _cryptoService.HasUserKeyAsync();
if (!hasKey) if (!hasKey)
@@ -544,14 +551,18 @@ namespace Bit.App.Pages
await _cryptoService.SetUserKeyAsync(key); await _cryptoService.SetUserKeyAsync(key);
} }
await _deviceTrustCryptoService.TrustDeviceIfNeededAsync(); await _deviceTrustCryptoService.TrustDeviceIfNeededAsync();
await DoContinueAsync(); await DoContinueAsync(shouldHandleHideLoading);
} }
private async Task DoContinueAsync() private async Task DoContinueAsync(bool shouldHandleHideLoading = false)
{ {
_syncService.FullSyncAsync(false).FireAndForget(); _syncService.FullSyncAsync(false).FireAndForget();
await _stateService.SetBiometricLockedAsync(false); await _stateService.SetBiometricLockedAsync(false);
_watchDeviceService.SyncDataToWatchAsync().FireAndForget(); _watchDeviceService.SyncDataToWatchAsync().FireAndForget();
if (shouldHandleHideLoading)
{
await MainThread.InvokeOnMainThreadAsync(_deviceActionService.HideLoadingAsync);
}
_messagingService.Send("unlocked"); _messagingService.Send("unlocked");
UnlockedAction?.Invoke(); UnlockedAction?.Invoke();
} }