From 7aea6458ce8d7345b791c81d53d85438bfb160be Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 25 Jun 2019 21:44:46 -0700 Subject: [PATCH] fix: Update email in auth service should update email in Outline --- server/auth/google.js | 5 +++++ server/auth/slack.js | 5 +++++ 2 files changed, 10 insertions(+) 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); });