validate player name
This commit is contained in:
parent
be8ff72ea4
commit
81a14fbfae
|
@ -29,9 +29,13 @@ public static class Program
|
||||||
|
|
||||||
app.MapPost("/player", (string name, Guid id) =>
|
app.MapPost("/player", (string name, Guid id) =>
|
||||||
{
|
{
|
||||||
|
name = name.Trim().ToUpperInvariant();
|
||||||
|
if (name == string.Empty)
|
||||||
|
return Results.BadRequest("name cannot be blank");
|
||||||
|
|
||||||
var player = playerService.GetOrAdd(name, id);
|
var player = playerService.GetOrAdd(name, id);
|
||||||
return player != null
|
return player != null
|
||||||
? Results.Ok(new NameId(name, id))
|
? Results.Ok(new NameId(player.Name, player.Id))
|
||||||
: Results.Unauthorized();
|
: Results.Unauthorized();
|
||||||
});
|
});
|
||||||
app.MapGet("/player", ([FromQuery] Guid id) =>
|
app.MapGet("/player", ([FromQuery] Guid id) =>
|
||||||
|
|
Loading…
Reference in a new issue