I'm using passportjs in order to log user and I try to redirect them after the password verify is complete with angularjs. But I keep getting "Cannot read property 'name' of undefined" when I try to get user data on another page Snippet:
app.post('/login', function(req, res, next) {
passport.authenticate('local', function(err, usr, info) {
res.locals.user = req.usr;
res.json({msg:true});
return next();
})(req, res, next);
});
And somewhere else I try to do something like this:
user.find({name: req.user.name },function(err,q){
Which fire the error "Cannot read property 'name' of undefined"