From d99d84d97d4174bff5be299953157a9d1b2f7cbf Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 9 Jun 2022 09:22:12 +0200 Subject: [PATCH] fix: Email cannot be found for some Azure sign-in accounts --- server/routes/auth/providers/azure.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/routes/auth/providers/azure.ts b/server/routes/auth/providers/azure.ts index 98dd047a6..9c2ad25ef 100644 --- a/server/routes/auth/providers/azure.ts +++ b/server/routes/auth/providers/azure.ts @@ -74,7 +74,13 @@ if (env.AZURE_CLIENT_ID && env.AZURE_CLIENT_SECRET) { } const organization = organizationResponse.value[0]; - const email = profile.email || profileResponse.mail; + + // Note: userPrincipalName is last here for backwards compatibility with + // previous versions of Outline that did not include it. + const email = + profile.email || + profileResponse.mail || + profileResponse.userPrincipalName; if (!email) { throw MicrosoftGraphError(