summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-10 00:55:11 +0100
committerTor Andersson <tor@ccxvii.net>2023-12-10 18:06:33 +0100
commit36e17b7cc92002d325d7f6fa93767f6189c51444 (patch)
tree80fc9c169bd1df16fe87bc358d40904cf42bd83a /server.js
parent80e3204596f9ab48a350a322e91d78b2a095cf33 (diff)
downloadserver-36e17b7cc92002d325d7f6fa93767f6189c51444.tar.gz
Show "join" page when not logged in.
Static page showing limited info and a call to action to login or sign up.
Diffstat (limited to 'server.js')
-rw-r--r--server.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/server.js b/server.js
index 7f87bf5..d964048 100644
--- a/server.js
+++ b/server.js
@@ -1789,7 +1789,7 @@ function update_join_clients_players(game_id) {
}
}
-app.get('/join/:game_id', must_be_logged_in, function (req, res) {
+app.get('/join/:game_id', function (req, res) {
let game_id = req.params.game_id | 0
let game = SQL_SELECT_GAME_VIEW.get(game_id)
if (!game)
@@ -1800,17 +1800,24 @@ app.get('/join/:game_id', must_be_logged_in, function (req, res) {
let roles = get_game_roles(game.title_id, game.scenario, options)
let players = SQL_SELECT_PLAYERS_JOIN.all(game_id)
- let whitelist = SQL_SELECT_CONTACT_WHITELIST.all(req.user.user_id)
- let blacklist = SQL_SELECT_CONTACT_BLACKLIST.all(req.user.user_id)
+
+ let whitelist = null
+ let blacklist = null
let friends = null
- if (game.owner_id === req.user.user_id)
- friends = SQL_SELECT_CONTACT_FRIEND_NAMES.all(req.user.user_id)
+
+ if (req.user) {
+ whitelist = SQL_SELECT_CONTACT_WHITELIST.all(req.user.user_id)
+ blacklist = SQL_SELECT_CONTACT_BLACKLIST.all(req.user.user_id)
+ if (game.owner_id === req.user.user_id)
+ friends = SQL_SELECT_CONTACT_FRIEND_NAMES.all(req.user.user_id)
+ }
+
let ready = (game.status === STATUS_OPEN) && is_game_ready(game.player_count, players)
game.ctime = human_date(game.ctime)
game.mtime = human_date(game.mtime)
res.render('join.pug', {
user: req.user, game, roles, players, ready, whitelist, blacklist, friends,
- limit: check_join_game_limit(req.user)
+ limit: req.user ? check_join_game_limit(req.user) : null
})
})