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() {
|
||||
$('#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;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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, ' ')
|
||||
|
Reference in New Issue
Block a user