From a73da0d736a50b7fb10f010b9ae4cc3e551c59e7 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Tue, 16 Jul 2019 18:42:28 -0400 Subject: Add email form --- src/server.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/server.js') diff --git a/src/server.js b/src/server.js index eae99e4..9899736 100644 --- a/src/server.js +++ b/src/server.js @@ -84,6 +84,7 @@ function setUpRoutes(models, jwtFunctions, database) { server.get('/index', (req, res) => res.sendFile(__dirname + "/html/index.html")) server.get('/admin', (req, res) => res.sendFile(__dirname + "/html/admin.html")); server.get('/login', (req, res) => res.sendFile(__dirname + "/html/login.html")) + server.get('/email', (req, res) => res.sendFile(__dirname + "/html/email.html")) server.get('/bread', (req, res) => res.sendFile(__dirname + "/html/bread.html")); server.get('/blog', (req, res) => res.sendFile(__dirname + "/html/blog.html")); server.get('/tags', (req, res) => res.sendFile(__dirname + "/html/tags.html")); @@ -175,6 +176,16 @@ function setUpRoutes(models, jwtFunctions, database) { res.redirect('/login'); } }) + server.post('/email', async (req, res, next) => { + const name = req.body.name; + const email = req.body.email; + if (name && email) { + models.emails.create({"name": name, "address": email}) + res.redirect('/email#success'); + } else { + console.debug("Error with email submission") + } + }) server.get('/favicon.ico', (req, res) => res.sendFile(__dirname + "/icon/favicon.ico")) -- cgit v1.2.3