Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Middleware Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshaviv committed Sep 9, 2013
1 parent 7fc5737 commit 84874bc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions config/middlewares/authorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

/**
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit 84874bc

Please sign in to comment.