From: Benjamin Auder <benjamin.auder@somewhere>
Date: Thu, 21 Nov 2019 11:28:21 +0000 (+0100)
Subject: 'update'
X-Git-Url: https://git.auder.net/variants/Chakart/%7B%7B%20asset%28%27mixstore/images/scripts/R.css?a=commitdiff_plain;h=098cd7f19e9ac858df6d635e5f37d356c1d5b1fa;p=vchess.git

'update'
---

diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue
index ac2cb27e..c47e89f1 100644
--- a/client/src/views/Hall.vue
+++ b/client/src/views/Hall.vue
@@ -398,6 +398,8 @@ export default {
       if (!!error)
         return alert(error);
       const ctype = this.classifyObject(this.newchallenge);
+      if (ctype == "corr" && this.st.user.id <= 0)
+        return alert("Please log in to play correspondance games");
       // NOTE: "from" information is not required here
       let chall = Object.assign({}, this.newchallenge);
       const finishAddChallenge = (cid,warnDisconnected) => {
diff --git a/server/models/Game.js b/server/models/Game.js
index 94056c57..954ffc40 100644
--- a/server/models/Game.js
+++ b/server/models/Game.js
@@ -104,6 +104,7 @@ const GameModel =
 			db.run(query, (err,gameIds) => {
 				if (!!err)
 					return cb(err);
+        gameIds = gameIds || []; //might be empty
 				let gameArray = [];
 				gameIds.forEach(gidRow => {
 					GameModel.getOne(gidRow["gid"], (err2,game) => {
diff --git a/server/routes/games.js b/server/routes/games.js
index d1f233bd..35a7f42f 100644
--- a/server/routes/games.js
+++ b/server/routes/games.js
@@ -56,9 +56,9 @@ router.get("/games", access.ajax, (req,res) => {
     const userId = req.query["uid"];
     const excluded = !!req.query["excluded"];
     GameModel.getByUser(userId, excluded, (err,games) => {
-		  access.checkRequest(res, err, games, "Games not found", () => {
-			  res.json({games: games});
-		  });
+		  if (!!err)
+        return res.json({errmsg: err.errmsg || err.toString()});
+			res.json({games: games});
 	  });
   }
 });