Added authentication logic to app
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user