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

Commit 84874bc

Browse files
committed
Middleware Fix
1 parent 7fc5737 commit 84874bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

config/middlewares/authorization.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
*/
44
exports.requiresLogin = function(req, res, next) {
55
if (!req.isAuthenticated()) {
6-
return res.redirect('/signin');
6+
return res.send(401, 'User is not authorized');
77
}
8-
next();
8+
next();
99
};
1010

1111
/**
@@ -14,7 +14,7 @@ exports.requiresLogin = function(req, res, next) {
1414
exports.user = {
1515
hasAuthorization: function(req, res, next) {
1616
if (req.profile.id != req.user.id) {
17-
return res.redirect('/users/' + req.profile.id);
17+
return res.send(401, 'User is not authorized');
1818
}
1919
next();
2020
}
@@ -26,7 +26,7 @@ exports.user = {
2626
exports.article = {
2727
hasAuthorization: function(req, res, next) {
2828
if (req.article.user.id != req.user.id) {
29-
return res.redirect('/articles/' + req.article.id);
29+
return res.send(401, 'User is not authorized');
3030
}
3131
next();
3232
}

0 commit comments

Comments
 (0)