I have an express route:
app.get('/', auth.authOrDie, function(req, res) { res.send(); });
where the authOrDie function authOrDie defined like this (in my auth.js module):
exports.authOrDie = function(req, res, next) { if (req.isAuthenticated()) { return next(); } else { res.send(403); } });
Now that the user is not authenticated, I would like to check if the HTTP request has an authorization header (Basic). For this, I would like to use the excellent basicAuth () middleware.
As you know, Express is built on top of Connect, so I can use express.basicAuth .
Commonly used by basicAuth :
app.get('/', express.basicAuth(function(username, password) {
But I would like to use it in my authOrDie function as follows:
exports.authOrDie = function(req, res, next) { if (req.isAuthenticated()) { return next(); } else if {
****** How can I call the basicAuth function with good parameters (req? Res? Next? ...).
Thanks.
source share