Save email address when making a new user with facebook oauth2
This commit is contained in:
@ -43,6 +43,8 @@ passport.use(new FacebookStrategy({
|
|||||||
callbackURL: config.facebook.callbackUrl || "http://localhost:8000/auth/facebook/callback"
|
callbackURL: config.facebook.callbackUrl || "http://localhost:8000/auth/facebook/callback"
|
||||||
},
|
},
|
||||||
function (accessToken, refreshToken, profile, done) {
|
function (accessToken, refreshToken, profile, done) {
|
||||||
|
console.log(profile);
|
||||||
|
|
||||||
User.findOne({ facebook: profile.id }, function(err, existingUser) {
|
User.findOne({ facebook: profile.id }, function(err, existingUser) {
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -56,7 +58,8 @@ passport.use(new FacebookStrategy({
|
|||||||
var user = new User({
|
var user = new User({
|
||||||
firstName: profile.name.givenName,
|
firstName: profile.name.givenName,
|
||||||
lastName: profile.name.familyName,
|
lastName: profile.name.familyName,
|
||||||
provider: profile.provider
|
provider: profile.provider,
|
||||||
|
email: profile._json.email
|
||||||
});
|
});
|
||||||
|
|
||||||
user[profile.provider] = profile.id;
|
user[profile.provider] = profile.id;
|
||||||
|
Reference in New Issue
Block a user