diff --git a/TanksServer/Endpoints.cs b/TanksServer/Endpoints.cs index f139715..a98c351 100644 --- a/TanksServer/Endpoints.cs +++ b/TanksServer/Endpoints.cs @@ -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(); diff --git a/tank-frontend/src/App.tsx b/tank-frontend/src/App.tsx index e065fc7..52631e6 100644 --- a/tank-frontend/src/App.tsx +++ b/tank-frontend/src/App.tsx @@ -11,9 +11,10 @@ import Scoreboard from "./Scoreboard.tsx"; import Button from "./components/Button.tsx"; import './App.css'; import {getRandomTheme, useStoredTheme} from "./theme.ts"; +import {EmptyGuid} from "./Guid.ts"; const getNewNameId = () => ({ - id: crypto.randomUUID(), + id: EmptyGuid, name: '' });