PCRB follow up client side logic
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
using MesaFabApproval.Client.Services;
|
||||
using MesaFabApproval.Shared.Models;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
using MudBlazor;
|
||||
|
||||
@ -13,8 +15,8 @@ public partial class AuthenticatedRedirect {
|
||||
[Inject] MesaFabApprovalAuthStateProvider authStateProvider { get; set; }
|
||||
[Inject] IAuthenticationService authService { get; set; }
|
||||
[Inject] IUserService userService { get; set; }
|
||||
[Inject] ISnackbar snackbar { get; set; }
|
||||
[Inject] NavigationManager navigationManager { get; set; }
|
||||
[Inject] IMemoryCache cache { get; set; }
|
||||
|
||||
private string? _jwt;
|
||||
private string? _refreshToken;
|
||||
@ -53,13 +55,16 @@ public partial class AuthenticatedRedirect {
|
||||
await authStateProvider.StateHasChanged(principal);
|
||||
}
|
||||
|
||||
AuthTokens authTokens = await authService.GetAuthTokens();
|
||||
|
||||
if (authStateProvider.CurrentUser is not null && !string.IsNullOrWhiteSpace(_redirectPath)) {
|
||||
navigationManager.NavigateTo(_redirectPath);
|
||||
} else {
|
||||
await authStateProvider.Logout();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_redirectPath)) {
|
||||
navigationManager.NavigateTo($"login/{_redirectPath}");
|
||||
cache.Set("redirectUrl", _redirectPath);
|
||||
navigationManager.NavigateTo($"login?redirectPath={_redirectPath}");
|
||||
} else {
|
||||
navigationManager.NavigateTo("login");
|
||||
}
|
||||
@ -68,7 +73,8 @@ public partial class AuthenticatedRedirect {
|
||||
await authStateProvider.Logout();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_redirectPath)) {
|
||||
navigationManager.NavigateTo($"login/{_redirectPath}");
|
||||
cache.Set("redirectUrl", _redirectPath);
|
||||
navigationManager.NavigateTo($"login?redirectPath={_redirectPath}");
|
||||
} else {
|
||||
navigationManager.NavigateTo("login");
|
||||
}
|
||||
|
Reference in New Issue
Block a user