Skip to content

Commit

Permalink
Merge pull request #245 from labzero/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
JeffreyATW authored Mar 26, 2019
2 parents d0d79ed + f531c77 commit b4e048c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"db:migrate": "./node_modules/.bin/sequelize db:migrate",
"db:migrate:undo:all": "./node_modules/.bin/sequelize db:migrate:undo:all",
"db:drop": "./node_modules/.bin/sequelize db:drop",
"debug": "npm run start -- --inspect",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"cypress:run-file": "cypress run --spec",
Expand Down
13 changes: 8 additions & 5 deletions src/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ passport.use(new GoogleStrategy(
},
async (accessToken, refreshToken, profile, done) => {
if (
typeof profile.emails === 'object'
&& profile.emails.length !== undefined
/* eslint-disable no-underscore-dangle */
profile._json
&& profile._json.email
) {
const accountEmail = profile.emails.find(email => email.type === 'account');
const accountEmail = profile._json.email;
/* eslint-enable no-underscore-dangle */

try {
// WARNING: this retrieves all attributes (incl. password).
// But we only provide the ID to passport.
Expand All @@ -48,14 +51,14 @@ passport.use(new GoogleStrategy(
// might not have been linked with Google yet
if (!user) {
user = await User.findOne({
where: { email: accountEmail.value }
where: { email: accountEmail }
});
userUpdates.google_id = profile.id;
doUpdates = true;
}

if (!user) {
return done(null, false, accountEmail.value);
return done(null, false, accountEmail);
}

if (
Expand Down

0 comments on commit b4e048c

Please sign in to comment.