feat: mint matchId and turnToken in PostStartMatch

This commit is contained in:
Keith Solomon
2026-07-25 22:52:34 -05:00
parent 3d8c1cfdb2
commit 9314fc5870
2 changed files with 47 additions and 1 deletions
+16 -1
View File
@@ -6,6 +6,7 @@ namespace BattleForge\Http\Handlers;
use BattleForge\Application\ScenarioDraft;
use BattleForge\Application\ScenarioSerializer;
use BattleForge\Application\TurnToken;
use BattleForge\Domain\ScenarioValidator;
use BattleForge\Http\CsrfToken;
use BattleForge\Http\Request;
@@ -36,6 +37,20 @@ final class PostStartMatch
return Response::json(400, ['errors' => [$exception->getMessage()]]);
}
return Response::json(200, ['match' => ScenarioSerializer::matchToArray($match)]);
$matchId = bin2hex(random_bytes(8));
$matchArray = ScenarioSerializer::matchToArray($match);
$turnToken = TurnToken::issue(
$secret,
$matchId,
$match->activeTeamId,
$match->round,
count($match->actionLog),
);
return Response::json(200, [
'match' => $matchArray,
'matchId' => $matchId,
'turnToken' => $turnToken,
]);
}
}