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