From d1a58a5a8c2f30278dc002a38f2f540a914bc677 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 23 May 2020 10:40:54 -0700 Subject: [PATCH] /register: Optionally use the session profile nickname for the player's name This allows a UI to set a nickname once in the profile and then send only the character name in the /register action. It's still supported to set the name in the /register action as well. --- empires.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/empires.js b/empires.js index a8c1771..d8cff6f 100644 --- a/empires.js +++ b/empires.js @@ -264,7 +264,13 @@ app.get('/', (request, response) => { app.post('/register', (request, response) => { const game = request.game; - game.add_player(request.body.name, request.body.character); + var name = request.session.nickname;; + + /* If the request includes a name, that overrides the session nickname. */ + if (request.body.name) + name = request.body.name; + + game.add_player(name, request.body.character); response.send(); }); -- 2.43.0