fix: Update email in auth service should update email in Outline

This commit is contained in:
Tom Moor
2019-06-25 21:44:46 -07:00
parent 424af9e72c
commit 7aea6458ce
2 changed files with 10 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);
});