Addressing CSRF and user status issues.

This commit is contained in:
David Jay
2017-01-09 15:39:08 -05:00
parent 0f24ab6b28
commit b8fc2c9cc7
8 changed files with 29 additions and 25 deletions
+10 -1
View File
@@ -125,7 +125,6 @@ router.post('/', (req, res, next) => {
});
router.post('/:user_id/actions', authorization.needed(), (req, res, next) => {
const {
action_type,
metadata
@@ -133,6 +132,16 @@ router.post('/:user_id/actions', authorization.needed(), (req, res, next) => {
User
.addAction(req.params.user_id, req.user.id, action_type, metadata)
.then((action) => {
// Set the user status to "pending" for review by moderators
if (action_type.slice(0, 4) === 'flag') {
return User.setStatus(req.user.id, 'pending')
.then(() => action);
} else {
return action;
}
})
.then((action) => {
res.status(201).json(action);
})