Fix things. Now on (live) game start + play
[vchess.git] / server / routes / messages.js
CommitLineData
582df349
BA
1// Router for contact form sending
2
298c42e6 3let router = require("express").Router();
8d7e2786 4const mailer = require(__dirname.replace("/routes", "/utils/mailer"));
298c42e6
BA
5
6// Send a message through contact form
7router.post("/messages", (req,res,next) => {
8 if (!req.xhr)
9 return res.json({errmsg: "Unauthorized access"});
8d7e2786 10 const from = req.body["email"];
298c42e6 11 const subject = req.body["subject"];
8d7e2786 12 const body = req.body["body"];
298c42e6 13 // TODO: sanitize ?
8d7e2786 14 mailer.send(from, mailer.contact, subject, body, err => {
298c42e6
BA
15 if (!!err)
16 return res.json({errmsg:err});
17 // OK, everything fine
18 res.json({}); //ignored
19 });
20});
21
22module.exports = router;