From 223a47af95d33cb60856663fa0aecbb473d9c026 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 2 Oct 2021 22:42:41 -0400 Subject: [PATCH] fix: Improve error when email field not returned from OIDC --- server/routes/auth/providers/oidc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/routes/auth/providers/oidc.js b/server/routes/auth/providers/oidc.js index 7127ce7d6..05c790a55 100644 --- a/server/routes/auth/providers/oidc.js +++ b/server/routes/auth/providers/oidc.js @@ -68,6 +68,11 @@ if (OIDC_CLIENT_ID) { // available on the `profile` parameter async function (req, accessToken, refreshToken, profile, done) { try { + if (!profile.email) { + throw new AuthenticationError( + `An email field was not returned in the profile parameter, but is required.` + ); + } const parts = profile.email.split("@"); const domain = parts.length && parts[1];