Add username/password auth and login UI
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user