Add OpenAPI contract and generated frontend client
This commit is contained in:
@@ -11,13 +11,13 @@ public static class AuthEndpoints
|
||||
{
|
||||
public static void MapAuthEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.MapGroup("/api/auth").RequireRateLimiting("auth-sensitive");
|
||||
var group = app.MapGroup("/api/auth").WithTags("Auth").RequireRateLimiting("auth-sensitive");
|
||||
|
||||
group.MapGet("/options", async (AppDbContext db) =>
|
||||
{
|
||||
var ownerExists = await db.Players.AsNoTracking().AnyAsync(p => p.IsOwner);
|
||||
return Results.Ok(new AuthOptionsResponse(ownerExists));
|
||||
});
|
||||
}).WithName("GetAuthOptions");
|
||||
|
||||
group.MapPost("/register", async ([FromBody] RegisterRequest request, HttpContext ctx, AppDbContext db, IConfiguration config, AuthAttemptMonitor authAttemptMonitor) =>
|
||||
{
|
||||
@@ -94,7 +94,7 @@ public static class AuthEndpoints
|
||||
player.DisplayName,
|
||||
player.IsAdmin
|
||||
));
|
||||
});
|
||||
}).WithName("Register");
|
||||
|
||||
group.MapPost("/login", async ([FromBody] LoginRequest request, HttpContext ctx, AppDbContext db, AuthAttemptMonitor authAttemptMonitor) =>
|
||||
{
|
||||
@@ -137,13 +137,13 @@ public static class AuthEndpoints
|
||||
player.DisplayName,
|
||||
player.IsAdmin
|
||||
));
|
||||
});
|
||||
}).WithName("Login");
|
||||
|
||||
group.MapPost("/logout", async (HttpContext ctx) =>
|
||||
{
|
||||
await PlayerIdentityExtensions.SignOutPlayerAsync(ctx);
|
||||
return Results.NoContent();
|
||||
});
|
||||
}).WithName("Logout");
|
||||
}
|
||||
|
||||
private static string NormalizeActor(string? username) => string.IsNullOrWhiteSpace(username) ? "(missing)" : username.Trim();
|
||||
|
||||
Reference in New Issue
Block a user