fix crypto.randomUUID() is not a function in an insecure context

This commit is contained in:
Vinzenz Schroeter 2024-04-19 13:29:51 +02:00
parent 25a3adea2a
commit 61f90b99af
2 changed files with 6 additions and 2 deletions

View file

@ -24,7 +24,10 @@ internal static class Endpoints
if (name.Length > 12)
return Results.BadRequest("name too long");
var player = playerService.GetOrAdd(name, id ?? Guid.NewGuid());
if (!id.HasValue || id.Value == Guid.Empty)
id = Guid.NewGuid();
var player = playerService.GetOrAdd(name, id.Value);
return player != null
? Results.Ok(new NameId(player.Name, player.Id))
: Results.Unauthorized();