Skip to content

Commit

Permalink
Return User email in userinfo endpoint (medplum#5907)
Browse files Browse the repository at this point in the history
* Return User email in userinfo endpoint

* PR feedback
  • Loading branch information
mattwiller authored Feb 4, 2025
1 parent ecd221b commit ecdb47f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/server/src/oauth/userinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ function buildProfile(userInfo: Record<string, any>, profile: ProfileResource):
}

function buildEmail(userInfo: Record<string, any>, profile: ProfileResource, user: User): void {
const contactPoint = profile.telecom?.find((cp) => cp.system === 'email');
if (contactPoint) {
userInfo.email = contactPoint.value;
userInfo.email_verified = !!(userInfo.email === user.email && user.emailVerified);
if (user.email) {
userInfo.email = user.email;
userInfo.email_verified = Boolean(user.emailVerified);
} else {
const contactPoint = profile.telecom?.find((cp) => cp.system === 'email');
if (contactPoint) {
userInfo.email = contactPoint.value;
userInfo.email_verified = false;
}
}
}

Expand Down

0 comments on commit ecdb47f

Please sign in to comment.