Scheduling infrastructure for absolutely everyone.
Fixed bug where null email address could occurr in office365 credential key
nicolas27194ef68c17
diff --git a/pages/api/integrations/office365calendar/callback.ts b/pages/api/integrations/office365calendar/callback.tsindex 9bb43d0e463..137157b0f29 100644--- a/pages/api/integrations/office365calendar/callback.ts+++ b/pages/api/integrations/office365calendar/callback.ts@@ -28,7 +28,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)const whoami = await fetch('https://graph.microsoft.com/v1.0/me', { headers: { 'Authorization': 'Bearer ' + responseBody.access_token } });const graphUser = await whoami.json();- responseBody.email = graphUser.mail;+ // In some cases, graphUser.mail is null. Then graphUser.userPrincipalName most likely contains the email address.+ responseBody.email = graphUser.mail ?? graphUser.userPrincipalName;responseBody.expiry_date = Math.round((+(new Date()) / 1000) + responseBody.expires_in); // set expiry date in secondsdelete responseBody.expires_in;