diff --git a/plugins/azure/server/auth/azure.ts b/plugins/azure/server/auth/azure.ts index 5517dc6531..820c64e3fd 100644 --- a/plugins/azure/server/auth/azure.ts +++ b/plugins/azure/server/auth/azure.ts @@ -8,6 +8,7 @@ import { slugifyDomain } from "@shared/utils/domains"; import { parseEmail } from "@shared/utils/email"; import accountProvisioner from "@server/commands/accountProvisioner"; import { MicrosoftGraphError } from "@server/errors"; +import Logger from "@server/logging/Logger"; import passportMiddleware from "@server/middlewares/passport"; import { User } from "@server/models"; import { AuthenticationResult } from "@server/types"; @@ -75,6 +76,18 @@ if (env.AZURE_CLIENT_ID && env.AZURE_CLIENT_SECRET) { ); } + if (!organizationResponse.value) { + Logger.info( + "authentication", + "API response missing value key", + organizationResponse + ); + + throw MicrosoftGraphError( + "Unable to load organization value from Microsoft Graph API" + ); + } + const organization = organizationResponse.value[0]; // Note: userPrincipalName is last here for backwards compatibility with