diff --git a/server/index.js b/server/index.js index a0b5d4d..c7d7202 100644 --- a/server/index.js +++ b/server/index.js @@ -123,11 +123,6 @@ function validatePledge(body, PledgeModel = Pledge) { // errors get saved here let errors = [] - let submit = body.submit - if (submit != 'Save Pledge') { - errors.push("This request seems to have been tampered with. Are you sure it wasn't you doing the tampering?") - } - let robo = body.robo if(robo != 'no') { errors.push('Only humans are allowed to donate money. Robots are too digital 🙁') @@ -194,6 +189,12 @@ function validatePledge(body, PledgeModel = Pledge) { router.post('/pledge', async (req, res) => { if (DEBUG) console.debug('New pledge:', req.body) + // check that the right submit button was pressed + let submit = req.body.submit + if (submit != 'Save Pledge') { + errors.push("This request seems to have been tampered with. Are you sure it wasn't you doing the tampering?") + } + // process the pledge with our handy function let {pledge, errors} = validatePledge(req.body, UnverifiedPledge)