From: Carl Worth Date: Sat, 23 May 2020 17:40:54 +0000 (-0700) Subject: /register: Optionally use the session profile nickname for the player's name X-Git-Url: https://git.cworth.org/git?p=empires-server;a=commitdiff_plain;h=d1a58a5a8c2f30278dc002a38f2f540a914bc677 /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. --- 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(); });