mirror of
https://github.com/sstent/expressmongotest.git
synced 2026-01-26 00:52:11 +00:00
almost rebased
This commit is contained in:
9
test/routes/middleware/restrict_user_to_self.js
Normal file
9
test/routes/middleware/restrict_user_to_self.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function restrictUserToSelf(req, res, next) {
|
||||
if (! req.session.user || req.session.user.username !== req.user.username) {
|
||||
res.send('Unauthorized', 401);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = restrictUserToSelf;
|
||||
Reference in New Issue
Block a user