Add username/password auth and login UI

This commit is contained in:
2026-01-29 01:01:13 +01:00
parent ca25d4f0ee
commit f1534b7631
21 changed files with 690 additions and 50 deletions

View File

@@ -25,7 +25,8 @@ public static class StateEndpoints
app.MapGet("/api/me", async (HttpContext ctx, AppDbContext db) =>
{
var player = await EndpointHelpers.GetOrCreatePlayer(ctx, db);
var player = await EndpointHelpers.GetAuthenticatedPlayer(ctx, db);
if (player is null) return Results.Unauthorized();
return Results.Ok(new { player.Id, player.DisplayName });
});
@@ -36,7 +37,9 @@ public static class StateEndpoints
return Results.BadRequest(new { error = "Name is required and must be <= 64 characters." });
}
var player = await EndpointHelpers.GetOrCreatePlayer(ctx, db);
var player = await EndpointHelpers.GetAuthenticatedPlayer(ctx, db);
if (player is null) return Results.Unauthorized();
player.DisplayName = request.Name.Trim();
await db.SaveChangesAsync();
return Results.Ok(new { player.Id, player.DisplayName });