Merge pull request #6116 from FreeCodeCamp/feature/camper-news-ban
Add banning to camper news
This commit is contained in:
@ -214,8 +214,12 @@ $(document).ready(function() {
|
|||||||
.fail(function() {
|
.fail(function() {
|
||||||
$('#story-submit').bind('click', storySubmitButtonHandler);
|
$('#story-submit').bind('click', storySubmitButtonHandler);
|
||||||
})
|
})
|
||||||
.done(function(data) {
|
.done(function({ storyLink, isBanned }) {
|
||||||
window.location = '/stories/' + data.storyLink;
|
if (isBanned) {
|
||||||
|
window.location = '/news';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
window.location = '/stories/' + storyLink;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,11 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"default": []
|
"default": []
|
||||||
},
|
},
|
||||||
|
"isBanned": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "User is banned from posting to camper news"
|
||||||
|
},
|
||||||
"isGithubCool": {
|
"isGithubCool": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
@ -399,10 +399,13 @@ module.exports = function(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function storySubmission(req, res, next) {
|
function storySubmission(req, res, next) {
|
||||||
var data = req.body.data;
|
if (req.user.isBanned) {
|
||||||
if (!req.user) {
|
return res.json({
|
||||||
return next(new Error('Not authorized'));
|
isBanned: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
var data = req.body.data;
|
||||||
|
|
||||||
var storyLink = data.headline
|
var storyLink = data.headline
|
||||||
.replace(/[^a-z0-9\s]/gi, '')
|
.replace(/[^a-z0-9\s]/gi, '')
|
||||||
.replace(/\s+/g, ' ')
|
.replace(/\s+/g, ' ')
|
||||||
|
Reference in New Issue
Block a user