Skip to content

Commit

Permalink
fix(users) patch OAuth default email issue
Browse files Browse the repository at this point in the history
- 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 meanjs#1250
  • Loading branch information
Daron Jones committed Sep 20, 2016
1 parent fe3adac commit 340ddb1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,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);
Expand Down

0 comments on commit 340ddb1

Please sign in to comment.