Remove test instructions, fix CORS for DELETE method
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 12 Mar 2019 16:36:02 +0000 (17:36 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 12 Mar 2019 16:36:02 +0000 (17:36 +0100)
client/src/views/Hall.vue
server/app.js
server/models/Challenge.js
server/routes/challenges.js

index 1d842d5..19f2e77 100644 (file)
@@ -125,10 +125,6 @@ export default {
   created: function() {
     // Always add myself to players' list
     this.players.push(this.st.user);
-
-    console.log("created");
-ajax("/testtest", "DELETE");
-
     // Ask server for current corr games (all but mines)
 //    ajax(
 //      "",
index d4aef28..13cf1db 100644 (file)
@@ -36,8 +36,9 @@ if (params.cors.enable)
        app.use(function(req, res, next) {
                res.header("Access-Control-Allow-Origin", params.cors.allowedOrigin);
                res.header("Access-Control-Allow-Headers",
-                       "Origin, X-Requested-With, Content-Type, Accept");
-               next();
+      "Origin, X-Requested-With, Content-Type, Accept");
+         res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE");
+    next();
        });
 }
 
index 8adf3ca..de2818b 100644 (file)
@@ -126,15 +126,6 @@ const ChallengeModel =
                });
        },
 
-  testfunc: function()
-  {
-    db.serialize(function() {
-      db.run("DELETE * FROM TableTest", (err,ret) => {
-        console.log(ret);
-      });
-    });
-  },
-
        remove: function(id, uid)
        {
                db.serialize(function() {
index 99f055f..40c50ec 100644 (file)
@@ -5,11 +5,6 @@ const access = require("../utils/access");
 const ChallengeModel = require("../models/Challenge");
 const UserModel = require("../models/User"); //for name check
 
-router.delete("/testtest", access.ajax, (req,res) => {
-  console.log("passag");
-  ChallengeModel.testfunc();
-});
-
 router.post("/challenges", access.logged, access.ajax, (req,res) => {
   const error = ChallengeModel.checkChallenge(req.body.chall);
   if (!!error)
@@ -70,7 +65,7 @@ router.post("/challenges", access.logged, access.ajax, (req,res) => {
 //}
 
 router.delete("/challenges", access.logged, access.ajax, (req,res) => {
-  const cid = req.query.cid;
+  const cid = req.query.id;
   ChallengeModel.remove(cid, req.userId, err => {
     res.json(err || {});
   });