mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-20 23:11:31 +02:00
Middleware Fix
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user