Hello I have a problem with everyauth: I don't know how to configure and get req.user in routes.
Can anybody help me with how to configure?
If you want to see more code just tell me. Thanks for visit
.password
// .loginWith('email')
.loginWith('login')
.getLoginPath('/login')
.postLoginPath('/login')
.loginView('login.jade')
.loginLocals( function (req, res, done) {
setTimeout( function () {
done(null, {
title: 'Async login'
});
}, 200);
})
.authenticate( function (login, password) {
var errors = [];
if (!login) errors.push('Missing login');
if (!password) errors.push('Missing password');
if (errors.length) return errors;
var user = usersByLogin[login];
if (!user) return ['Login failed'];
if (user.password !== password) return ['Login failed'];
return user;
})
redirect code:
app.get('/home', function(req,res)
{
if(req.session.auth)
{
console.log(req.user); //undefined
res.send('youre logged in');
}
});
You need to provide everyauth a way of looking up your user object from its id by calling:
See the Accessing the User section of the everyauth website.