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:
@@ -7,6 +7,11 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
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();
|
var auth = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||||
if (auth.User.Identity?.IsAuthenticated != true) return;
|
if (auth.User.Identity?.IsAuthenticated != true) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user