Added authentication logic to app

This commit is contained in:
Khwezi Mngoma
2026-05-16 20:12:35 +02:00
parent 5fd12b34ac
commit 3bdf897ac8
4 changed files with 67 additions and 3 deletions
+12 -2
View File
@@ -1,5 +1,7 @@
@page "/login"
@using Microsoft.AspNetCore.Components.Authorization
@inject NavigationManager Navigation
@rendermode InteractiveServer
<div class="auth-workspace-canvas">
<div class="tech-background-matrix">
@@ -67,8 +69,16 @@
[CascadingParameter]
private Task<AuthenticationState>? AuthState { get; set; }
private void HandleLogin()
protected override async Task OnInitializedAsync()
{
// Wire up your OAuth / OpenID Connect Redirect or Auth trigger state here
if (AuthState is not null)
{
var state = await AuthState;
if (state.User.Identity?.IsAuthenticated ?? false)
Navigation.NavigateTo("/", replace: true);
}
}
private void HandleLogin() => Navigation.NavigateTo("/auth/login", forceLoad: true);
}