Middleware Fix

This commit is contained in:
Amos Haviv
2013-09-09 12:32:59 +03:00
parent 7fc57379b4
commit 84874bce5e

View File

@@ -3,9 +3,9 @@
*/
exports.requiresLogin = function(req, res, next) {
if (!req.isAuthenticated()) {
return res.redirect('/signin');
return res.send(401, 'User is not authorized');
}
next();
next();
};
/**
@@ -14,7 +14,7 @@ exports.requiresLogin = function(req, res, next) {
exports.user = {
hasAuthorization: function(req, res, next) {
if (req.profile.id != req.user.id) {
return res.redirect('/users/' + req.profile.id);
return res.send(401, 'User is not authorized');
}
next();
}
@@ -26,7 +26,7 @@ exports.user = {
exports.article = {
hasAuthorization: function(req, res, next) {
if (req.article.user.id != req.user.id) {
return res.redirect('/articles/' + req.article.id);
return res.send(401, 'User is not authorized');
}
next();
}