Skip to content

Instantly share code, notes, and snippets.

@deedubs
Created February 21, 2012 18:20
Show Gist options
  • Save deedubs/1877950 to your computer and use it in GitHub Desktop.
Save deedubs/1877950 to your computer and use it in GitHub Desktop.
Post Ban
app.post('/user/ban/:userId', function(req, res){
req.user.bannedReason = req.body.bannedReason;
req.user.banned = true;
console.log(req.user.id)
req.user.save(function(err) {
if (err) {
req.flash('info','User banned:' + req.body.bannedReason);
} else {
req.flash('info','User cannot be banned');
}
res.redirect('back');
});
});
app.post('/user/ban/:userId', function(req, res){
var user = req.user;
user.bannedReason = req.body.bannedReason;
user.banned = true;
user.save(function(err) {
if (!err) {
req.flash('info','User banned:' + req.body.bannedReason);
} else {
req.flash('error','User cannot be banned');
}
res.redirect('back');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment