Merge pull request #6116 from FreeCodeCamp/feature/camper-news-ban

Add banning to camper news
This commit is contained in:
Quincy Larson
2016-01-13 01:20:05 -06:00
3 changed files with 17 additions and 5 deletions

View File

@ -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;
});
};

View File

@ -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

View File

@ -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, ' ')