@page "/"
@attribute [Authorize]
@using Iceshrimp.Frontend.Core.Services
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@inject SessionService Session
@inject NavigationManager Navigation
Timeline
@if (username != null)
{
You are logged in as @username
Authorization says you are @context.User.Identity!.Name
}else
{
Not logged in
}
@code {
private string? username;
protected override void OnInitialized()
{
if (Session.Current != null)
{
username = Session.Current.Username;
}
}
public void Logout()
{
Session.EndSession();
Navigation.NavigateTo("/login");
}
}