diff --git a/src/AliasVault.Client/Auth/Pages/Unlock.razor b/src/AliasVault.Client/Auth/Pages/Unlock.razor index 2537bd47c..a74a49cee 100644 --- a/src/AliasVault.Client/Auth/Pages/Unlock.razor +++ b/src/AliasVault.Client/Auth/Pages/Unlock.razor @@ -9,6 +9,9 @@ @using AliasVault.Shared.Models.WebApi.Auth @using AliasVault.Cryptography.Client + + + @if (IsLoading) { @@ -38,7 +41,7 @@ else Unlock with WebAuthn @@ -49,9 +52,6 @@ else Enter your master password to unlock your database.

- - -
@@ -94,10 +94,7 @@ else { // Trigger status API call to check if the user is still authenticated. // If user is not authenticated a redirect to the login page will be triggered automatically. - await Task.WhenAll( - Http.GetAsync("api/v1/Auth/status"), - StatusCheck() - ); + await StatusCheck(); // Always check if WebAuthn is enabled ShowWebAuthnButton = await AuthService.IsWebAuthnEnabledAsync(); @@ -124,7 +121,6 @@ else try { await StatusCheck(); - await Http.GetAsync("api/v1/Auth/status"); // Send request to server with email to get user salt. var result = await Http.PostAsJsonAsync("api/v1/Auth/login", new LoginInitiateRequest(Username!)); @@ -137,6 +133,7 @@ else { _serverValidationErrors.AddError(error); } + return; } @@ -230,6 +227,20 @@ else GlobalNotificationService.ClearMessages(); GlobalNotificationService.AddErrorMessage("Your session has timed out. Please log in again."); NavigationManager.NavigateTo("/user/login"); + return; + } + + // Make a request to the server to check if the user is still authenticated. + // If user has no valid authentication an automatic redirect to login page will take place. + try + { + await Http.GetAsync("api/v1/Auth/status"); + } + catch (Exception ex) + { + _serverValidationErrors.AddError("Connection with the AliasVault servers failed. Please try again (later)."); + Logger.LogError(ex, "An error occurred while checking the user status."); + StateHasChanged(); } }