fix(dashboard)!: move login POST to /auth/login to resolve AmbiguousMatchException
The themed Blazor <LoginCard> page (Components/Pages/Login.razor, @page "/login")
registers a Razor Components endpoint that matches ALL HTTP methods. The credential
form POSTed to /login, where MapPost("/login") also matched — so every POST /login
threw Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException (HTTP 500),
breaking dashboard login for every user. It was latent because the dashboard was only
ever reached via the AllowAnonymousLocalhost bypass on the host box.
Move the credential POST to a distinct /auth/login route (mirroring ScadaBridge, which
never collided because it posts to /auth/login). GET /login stays the Blazor page; the
cookie LoginPath stays /login. Adds a registration assertion pinning DashboardLoginPost
to /auth/login as the regression guard.
Files: Login.razor (LoginCard Action), DashboardEndpointRouteBuilderExtensions (MapPost
route), GatewayApplicationTests (route assertion).
This commit is contained in:
@@ -87,13 +87,18 @@ public sealed class GatewayApplicationTests
|
||||
Assert.Contains(endpoints, endpoint => endpoint.RoutePattern.RawText == "/events");
|
||||
Assert.Contains(endpoints, endpoint => endpoint.RoutePattern.RawText == "/settings");
|
||||
|
||||
// GET /login is now served by the [AllowAnonymous] Blazor <Login> component
|
||||
// GET /login is served by the [AllowAnonymous] Blazor <Login> component
|
||||
// (Components/Pages/Login.razor → @page "/login"), not a named minimal-API
|
||||
// endpoint. The form still POSTs to the minimal-API DashboardLoginPost endpoint.
|
||||
// endpoint. The credential POST goes to the DashboardLoginPost endpoint at
|
||||
// /auth/login — a DISTINCT route. The Blazor component endpoint matches all HTTP
|
||||
// methods, so sharing the "/login" route with MapPost previously made POST /login
|
||||
// ambiguous (AmbiguousMatchException → HTTP 500). Pinning the POST to /auth/login
|
||||
// is the regression guard for that fix.
|
||||
Assert.Contains(endpoints, endpoint => endpoint.RoutePattern.RawText == "/login"
|
||||
&& endpoint.Metadata.GetMetadata<Microsoft.AspNetCore.Components.Endpoints.ComponentTypeMetadata>() is not null);
|
||||
Assert.Contains(endpoints, endpoint =>
|
||||
endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()?.EndpointName == "DashboardLoginPost");
|
||||
endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()?.EndpointName == "DashboardLoginPost"
|
||||
&& endpoint.RoutePattern.RawText == "/auth/login");
|
||||
Assert.Contains(endpoints, endpoint =>
|
||||
endpoint.Metadata.GetMetadata<IEndpointNameMetadata>()?.EndpointName == "DashboardLogout");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user