stefanbuck / sails-social-auth-example

Sails.js Social Auth example with Passport and MongoDB
243 stars 62 forks source link

Getting username from the req.user #32

Closed prem-kumar-e closed 9 years ago

prem-kumar-e commented 9 years ago

How do i get the username and other details of the logged in user. Now I am getting only the below by using "req.user" { email: 'xxxr@xyx.com', createdAt: '2015-08-12T10:47:25.404Z', updatedAt: '2015-08-12T10:47:25.405Z', id: '55cb243d8bbd86d5237c2f7f' }

stefanbuck commented 9 years ago

You have to use the user model like this

User.findOne({uid:  '55cb243d8bbd86d5237c2f7f'}, function(err, user) {
   console.log(user.username)
});