var express = require('express'),
    bodyParser = require('body-parser'),
    app = express(),
    port = process.env.PORT || 3000,
    server = app.listen(port);

app.use(bodyParser.urlencoded());
app.use(express.static(__dirname + '/static'));

app.get('/', function (req, res) {
    res.send(__dirname + '/static/index.html');
});

app.post('/', function (req, res) {
    var payload = req.body;
    console.log(payload);
    //get webhook
    //check if user_name is on approved list
        //if not, respond with message to user
        //if so, send empty 200 response
            //then send message to webhook, formatted as ministry
});
@@ -325,24 +325,297 @@
 tml');%0A%7D);%0A%0A
+function isValidToken (payload) %7B%0A    var token = process.env.TOKEN;%0A    return payload.token === token;%0A%7D%0A%0Afunction isApprovedUser (payload) %7B%0A    var approvedUsers = %5B'ross', 'itsmerossw', 'libby', 'moose'%5D;%0A    return approvedUsers.indexOf(payload.user_name) !== -1;%0A%7D%0A%0A
 app.post('/'
@@ -670,33 +670,249 @@
 dy;%0A
+%0A
     
-console.log(payload);
+if (isValidToken(payload)) %7B%0A        if (isApprovedUser(payload)) %7B%0A            res.send('You are an approved Ministry member.');%0A        %7D else %7B%0A            res.send('Sorry - you are not an approved Ministry member.');%0A        %7D%0A    %7D
 %0A   

check token and users