'update'
authorBenjamin Auder <benjamin.auder@somewhere>
Thu, 21 Nov 2019 11:28:21 +0000 (12:28 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Thu, 21 Nov 2019 11:28:21 +0000 (12:28 +0100)
client/src/views/Hall.vue
server/models/Game.js
server/routes/games.js

index ac2cb27..c47e89f 100644 (file)
@@ -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) => {
index 94056c5..954ffc4 100644 (file)
@@ -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) => {
index d1f233b..35a7f42 100644 (file)
@@ -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});
          });
   }
 });