diff --git a/client/main.js b/client/main.js index 99beae1720..b677fc2b80 100644 --- a/client/main.js +++ b/client/main.js @@ -214,8 +214,12 @@ $(document).ready(function() { .fail(function() { $('#story-submit').bind('click', storySubmitButtonHandler); }) - .done(function(data) { - window.location = '/stories/' + data.storyLink; + .done(function({ storyLink, isBanned }) { + if (isBanned) { + window.location = '/news'; + return null; + } + window.location = '/stories/' + storyLink; }); }; diff --git a/common/models/user.json b/common/models/user.json index e39ce0e8b1..40fecf6f47 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -23,6 +23,11 @@ "type": "array", "default": [] }, + "isBanned": { + "type": "boolean", + "default": false, + "description": "User is banned from posting to camper news" + }, "isGithubCool": { "type": "boolean", "default": false diff --git a/server/boot/story.js b/server/boot/story.js index 081de5a866..516ce9e268 100755 --- a/server/boot/story.js +++ b/server/boot/story.js @@ -399,10 +399,13 @@ module.exports = function(app) { } function storySubmission(req, res, next) { - var data = req.body.data; - if (!req.user) { - return next(new Error('Not authorized')); + if (req.user.isBanned) { + return res.json({ + isBanned: true + }); } + var data = req.body.data; + var storyLink = data.headline .replace(/[^a-z0-9\s]/gi, '') .replace(/\s+/g, ' ')