Added authenication/authorization. Refactored api startup.
Some checks failed
ci / build-test (push) Has been cancelled
ci / publish-image (push) Has been cancelled

This commit is contained in:
2026-02-16 00:20:02 -05:00
parent a85989a337
commit 9f30ef446a
25 changed files with 685 additions and 154 deletions

View File

@@ -1,4 +1,20 @@
@inherits LayoutComponentBase
@using JSMR.UI.Blazor.Services
@inject SessionState Session
@inherits LayoutComponentBase
<div class="topbar">
@if (Session.IsAuthenticated)
{
<span>Logged in as <b>@Session.Me?.name</b> (@Session.Me?.role)</span>
<a href="" @onclick="OnLogout" style="margin-left: 12px;">Logout</a>
}
else
{
<a href="/login">Login</a>
}
</div>
<MudLayout>
<MudAppBar Elevation="1" Dense="@_dense">
@@ -56,4 +72,21 @@
StateHasChanged();
}
}
protected override void OnInitialized()
{
Session.Changed += OnSessionChanged;
}
private void OnSessionChanged() => InvokeAsync(StateHasChanged);
private async Task OnLogout(MouseEventArgs _)
{
await Session.LogoutAsync();
}
public void Dispose()
{
Session.Changed -= OnSessionChanged;
}
}