From 7f2b16f6016645ac04d2ae63b329202e173f553f Mon Sep 17 00:00:00 2001 From: Oscar Veldman Date: Sat, 23 Mar 2024 19:14:47 +0100 Subject: [PATCH] Refactor login forms --- .../Components/Pages/Authentications/Login.razor | 13 ++++++++++--- .../Components/Pages/Authentications/Logout.razor | 8 +++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sources/Clients.Admin/Components/Pages/Authentications/Login.razor b/sources/Clients.Admin/Components/Pages/Authentications/Login.razor index 47aff6c..14707dc 100644 --- a/sources/Clients.Admin/Components/Pages/Authentications/Login.razor +++ b/sources/Clients.Admin/Components/Pages/Authentications/Login.razor @@ -18,11 +18,18 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender) + if (!firstRender) { - await AuthenticationManager.LoginFromSessionAsync(); - StateHasChanged(); + return; } + + var result = await AuthenticationManager.LoginFromSessionAsync(); + if (result.IsSuccess) + { + NavigationManager.NavigateTo("/AuthenticationTest"); + } + + StateHasChanged(); } private async Task TryLogin() diff --git a/sources/Clients.Admin/Components/Pages/Authentications/Logout.razor b/sources/Clients.Admin/Components/Pages/Authentications/Logout.razor index 776ce5c..ac233d2 100644 --- a/sources/Clients.Admin/Components/Pages/Authentications/Logout.razor +++ b/sources/Clients.Admin/Components/Pages/Authentications/Logout.razor @@ -9,11 +9,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender) + if (!firstRender) { - await AuthenticationManager.LogoutAsync(); - StateHasChanged(); + return; } + + await AuthenticationManager.LogoutAsync(); + StateHasChanged(); } } \ No newline at end of file