From 340ddb13981a543e5f4f8d8f5ed181a40c20972e Mon Sep 17 00:00:00 2001 From: Daron Jones Date: Sun, 11 Sep 2016 01:28:40 +0100 Subject: [PATCH] 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 --- .../users/users.authentication.server.controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/users/server/controllers/users/users.authentication.server.controller.js b/modules/users/server/controllers/users/users.authentication.server.controller.js index 56a962e8e9..6d843462c3 100644 --- a/modules/users/server/controllers/users/users.authentication.server.controller.js +++ b/modules/users/server/controllers/users/users.authentication.server.controller.js @@ -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);