diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-11-09 23:15:50 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-11-09 23:15:50 +0100 |
commit | ac7792ab371f8ee17804539b564a4a13b539ab73 (patch) | |
tree | 9bd0ef38c32c72e7fedd61fef1af906c51a16247 /server.js | |
parent | 023c7e0c87ee0ff96b17cd4e4a3b0915d1c223d1 (diff) | |
download | server-ac7792ab371f8ee17804539b564a4a13b539ab73.tar.gz |
Handle missing users.
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1536,10 +1536,15 @@ app.get('/games', must_be_logged_in, function (req, res) { app.get('/user/:who_id', function (req, res) { LOG(req, "GET /user/" + req.params.who_id); let who = sql_fetch_user_by_name.get(req.params.who_id, req.params.who_id); - who.avatar = get_avatar(who.mail); - who.ctime = human_date(who.ctime); - who.atime = human_date(who.atime); - res.render('user.ejs', { user: req.user, who: who, message: req.flash('message') }); + if (who) { + who.avatar = get_avatar(who.mail); + who.ctime = human_date(who.ctime); + who.atime = human_date(who.atime); + res.render('user.ejs', { user: req.user, who: who, message: req.flash('message') }); + } else { + req.flash('message', "Cannot find that user."); + return res.redirect('/'); + } }); // FORUM |