1
0

Fix initial cookie display during handshake;

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-03-13 14:12:49 -07:00
parent 5db9139b5c
commit d42070ed36

View File

@ -3898,10 +3898,16 @@ const shuffleBoard = (game) => {
/* Simple NO-OP to set session cookie so player-id can use it as the
* index */
router.get("/", (req, res/*, next*/) => {
let playerId;
if (!req.cookies.player) {
res.cookie('player', crypto.randomBytes(16).toString('hex'));
playerId = crypto.randomBytes(16).toString('hex');
res.cookie('player', playerId);
} else {
playerId = req.cookies.player;
}
console.log(`[${req.cookies.player.substring(0, 8)}]: Browser hand-shake has started.`)
console.log(`[${req.cookies.player.substring(0, 8)}]: Browser hand-shake has started.`);
return res.status(200).send({ player: req.cookies.player });
});