I'm using express and adding in basic authentication via the connect middleware. I'm trying to use the async version and it claims the user
property will be set on the request object when calling using the async version.
If I call the proper fn(err, obj);
with an object then the basic authentication passes and moves onto my routes, but I want to have the req.user
set when it gets to my route.
Here is the connect doc on basic auth.
Am I not calling the callback properly?
app.use(express.basicAuth(function(user, pass, fn){
db.getUserByEmail(user, function(err, obj){
if (err) sendError(500, req, 'error', err);
else if (obj == null) fn(err, obj);
else if (obj.password == pass) fn(null, obj);
else fn(null, null);
});
}));