mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-10 23:53:31 -05:00
Add scope middleware to invites
This commit is contained in:
parent
6c89cdd29e
commit
4b4d32ec9c
@ -3,6 +3,18 @@ var router = express.Router();
|
||||
|
||||
var Invite = require('../models/Invite.js');
|
||||
|
||||
var requireScope = function (perm) {
|
||||
return function(req, res, next) {
|
||||
User.findOne({username: req.session.passport.user}, function(err, user) {
|
||||
if (err) throw err;
|
||||
if (user.scope.indexOf(perm) === -1)
|
||||
res.status(400).json({'message': 'No permission.'});
|
||||
else
|
||||
next();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
router.post('/create', function (req, res) {
|
||||
if (!req.body.scope) {
|
||||
res.status(400).json({'message': 'Bad request.'});
|
||||
|
Loading…
Reference in New Issue
Block a user