From 84874bce5e0e5b5f723cbc4f3fc994f770c3fbca Mon Sep 17 00:00:00 2001 From: Amos Haviv Date: Mon, 9 Sep 2013 12:32:59 +0300 Subject: [PATCH] Middleware Fix --- config/middlewares/authorization.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/middlewares/authorization.js b/config/middlewares/authorization.js index eba6f316..d5f236c5 100755 --- a/config/middlewares/authorization.js +++ b/config/middlewares/authorization.js @@ -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(); }