Imported MEAN stack files

This commit is contained in:
Sahat Yalkabov
2013-11-13 12:32:22 -05:00
parent 276673cc47
commit d4b651a5c8
68 changed files with 1819 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
/**
* Generic require login routing middleware
*/
exports.requiresLogin = function(req, res, next) {
if (!req.isAuthenticated()) {
return res.send(401, 'User is not authorized');
}
next();
};
/**
* User authorizations routing middleware
*/
exports.user = {
hasAuthorization: function(req, res, next) {
if (req.profile.id != req.user.id) {
return res.send(401, 'User is not authorized');
}
next();
}
};
/**
* Article authorizations routing middleware
*/
exports.article = {
hasAuthorization: function(req, res, next) {
if (req.article.user.id != req.user.id) {
return res.send(401, 'User is not authorized');
}
next();
}
};