fix(users) Handle missing email - OAuth (#1501)

* fix(users) patch OAuth default email issue

- Intentionally omits setting email in constructor to trigger defaults when
creating user. Handles cases where email is not authorized/given by provider.

Related to issue #1250
This commit is contained in:
Daron Jones
2016-09-21 05:24:16 +01:00
committed by Michael Leanos
parent 89e8d13c47
commit e3eafa6131

View File

@@ -160,12 +160,16 @@ exports.saveOAuthUserProfile = function (req, providerUserProfile, done) {
lastName: providerUserProfile.lastName,
username: availableUsername,
displayName: providerUserProfile.displayName,
email: providerUserProfile.email,
profileImageURL: providerUserProfile.profileImageURL,
provider: providerUserProfile.provider,
providerData: providerUserProfile.providerData
});
// Email intentionally added later to allow defaults (sparse settings) to be applid.
// Handles case where no email is supplied.
// See comment: https://github.com/meanjs/mean/pull/1495#issuecomment-246090193
user.email = providerUserProfile.email;
// And save the user
user.save(function (err) {
return done(err, user, info);