Require display name before suggesting/voting and enforce in UI
This commit is contained in:
@@ -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." });
|
||||
|
||||
Reference in New Issue
Block a user