Require display name before suggesting/voting and enforce in UI

This commit is contained in:
2026-01-28 16:30:30 +01:00
parent e49fb04e3a
commit 6396d583b5
3 changed files with 38 additions and 0 deletions

View File

@@ -178,6 +178,11 @@ api.MapPost("/suggestions", async ([FromBody] SuggestionRequest request, HttpCon
var player = await GetOrCreatePlayer(ctx, db);
if (string.IsNullOrWhiteSpace(player.DisplayName))
{
return Results.BadRequest(new { error = "Set a display name before submitting suggestions." });
}
var existingCount = await db.Suggestions.CountAsync(s => s.PlayerId == player.Id);
if (existingCount >= 3)
{
@@ -263,6 +268,9 @@ api.MapPost("/votes", async ([FromBody] VoteRequest request, HttpContext ctx, Ap
var player = await GetOrCreatePlayer(ctx, db);
if (string.IsNullOrWhiteSpace(player.DisplayName))
return Results.BadRequest(new { error = "Set a display name before voting." });
var suggestionExists = await db.Suggestions.AnyAsync(s => s.Id == request.SuggestionId);
if (!suggestionExists)
return Results.BadRequest(new { error = "Suggestion not found." });