mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03: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:
parent
13ca0fd4cb
commit
12385d9add
1 changed files with 16 additions and 5 deletions
|
@ -285,6 +285,8 @@ namespace Bit.App.Pages
|
|||
var failed = true;
|
||||
try
|
||||
{
|
||||
await MainThread.InvokeOnMainThreadAsync(() => _deviceActionService.ShowLoadingAsync(AppResources.Loading));
|
||||
|
||||
EncString userKeyPin;
|
||||
EncString oldPinProtected;
|
||||
switch (_pinStatus)
|
||||
|
@ -333,21 +335,26 @@ namespace Bit.App.Pages
|
|||
{
|
||||
Pin = string.Empty;
|
||||
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
|
||||
}
|
||||
}
|
||||
catch (LegacyUserException)
|
||||
{
|
||||
await MainThread.InvokeOnMainThreadAsync(_deviceActionService.HideLoadingAsync);
|
||||
throw;
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Exception(ex);
|
||||
failed = true;
|
||||
}
|
||||
if (failed)
|
||||
{
|
||||
var invalidUnlockAttempts = await AppHelpers.IncrementInvalidUnlockAttemptsAsync();
|
||||
|
||||
await MainThread.InvokeOnMainThreadAsync(_deviceActionService.HideLoadingAsync);
|
||||
|
||||
if (invalidUnlockAttempts >= 5)
|
||||
{
|
||||
_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();
|
||||
if (!hasKey)
|
||||
|
@ -544,14 +551,18 @@ namespace Bit.App.Pages
|
|||
await _cryptoService.SetUserKeyAsync(key);
|
||||
}
|
||||
await _deviceTrustCryptoService.TrustDeviceIfNeededAsync();
|
||||
await DoContinueAsync();
|
||||
await DoContinueAsync(shouldHandleHideLoading);
|
||||
}
|
||||
|
||||
private async Task DoContinueAsync()
|
||||
private async Task DoContinueAsync(bool shouldHandleHideLoading = false)
|
||||
{
|
||||
_syncService.FullSyncAsync(false).FireAndForget();
|
||||
await _stateService.SetBiometricLockedAsync(false);
|
||||
_watchDeviceService.SyncDataToWatchAsync().FireAndForget();
|
||||
if (shouldHandleHideLoading)
|
||||
{
|
||||
await MainThread.InvokeOnMainThreadAsync(_deviceActionService.HideLoadingAsync);
|
||||
}
|
||||
_messagingService.Send("unlocked");
|
||||
UnlockedAction?.Invoke();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue