diff --git a/server/auth/google.js b/server/auth/google.js index 61645e438..9c18cea05 100644 --- a/server/auth/google.js +++ b/server/auth/google.js @@ -91,6 +91,11 @@ router.get('google.callback', auth({ required: false }), async ctx => { }, }); + // update email address if it's changed in Google + if (!isFirstSignin && profile.data.email !== user.email) { + await user.update({ email: profile.data.email }); + } + if (isFirstUser) { await team.provisionFirstCollection(user.id); await team.provisionSubdomain(hostname); diff --git a/server/auth/slack.js b/server/auth/slack.js index 6b39ede22..7e1171df6 100644 --- a/server/auth/slack.js +++ b/server/auth/slack.js @@ -69,6 +69,11 @@ router.get('slack.callback', auth({ required: false }), async ctx => { await team.provisionSubdomain(data.team.domain); } + // update email address if it's changed in Slack + if (!isFirstSignin && data.user.email !== user.email) { + await user.update({ email: data.user.email }); + } + // set cookies on response and redirect to team subdomain ctx.signIn(user, team, 'slack', isFirstSignin); });