fix(ui/auth): stop /login redirect loop when the session is expired

SessionExpiry renders inside MainLayout, which also wraps the login
page. For a user with a still-present auth cookie but an expired
expires_at claim, it redirected /login back to /login indefinitely.
It now skips the redirect when already on the login page.
This commit is contained in:
Joseph Doherty
2026-05-15 12:14:57 -04:00
parent 1d5465f31c
commit fc18239b97

View File

@@ -7,6 +7,11 @@
protected override async Task OnInitializedAsync()
{
// The login page uses the same layout, so this component renders there
// too. Redirecting /login → /login would loop ("too many redirects").
var path = Navigation.ToBaseRelativePath(Navigation.Uri);
if (path.StartsWith("login", StringComparison.OrdinalIgnoreCase)) return;
var auth = await AuthStateProvider.GetAuthenticationStateAsync();
if (auth.User.Identity?.IsAuthenticated != true) return;