I'm using NodeJS, express, and passport. However I think this question is just about javascript. In my routes file, I have
app.get( '/users', login_req, user.index);
so when the server receives a get request at /users, it will pass req, res, next
through the login_req function, and login_req will call the user.index function if a user is authorized. I'm wondering if and how I can add more arguments to login_req? My goal is to be able to pass in additional args like login_req(['admin'],['user1', 'user2'])
to be able to select which users have access to user.index.
Here is my login_req code:
exports.login_req = function(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login')
}
I guess, in general, I'm wondering how to attach more arguments to a callback.