fix: Lowercase email from auth providers to match any outstanding invites (#3369)

* fix: Lowercase email from auth providers to match any outstanding invites

* fix
This commit is contained in:
Tom Moor
2022-04-12 21:31:55 -07:00
committed by GitHub
parent 1de732c82a
commit d3ecab3489
5 changed files with 8 additions and 10 deletions

View File

@@ -40,7 +40,7 @@ if (AZURE_CLIENT_ID) {
try {
// see docs for what the fields in profile represent here:
// https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens
const profile = jwt.decode(params.id_token);
const profile = jwt.decode(params.id_token) as jwt.JwtPayload;
// Load the users profile from the Microsoft Graph API
// https://docs.microsoft.com/en-us/graph/api/resources/users?view=graph-rest-1.0
@@ -69,7 +69,6 @@ if (AZURE_CLIENT_ID) {
}
const organization = organizationResponse.value[0];
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
const email = profile.email || profileResponse.mail;
if (!email) {
@@ -89,19 +88,15 @@ if (AZURE_CLIENT_ID) {
subdomain,
},
user: {
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
name: profile.name,
email,
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
avatarUrl: profile.picture,
},
authenticationProvider: {
name: providerName,
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
providerId: profile.tid,
},
authentication: {
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
providerId: profile.oid,
accessToken,
refreshToken,

View File

@@ -61,8 +61,8 @@ if (GOOGLE_CLIENT_ID) {
subdomain,
},
user: {
name: profile.displayName,
email: profile.email,
name: profile.displayName,
avatarUrl: profile.picture,
},
authenticationProvider: {

View File

@@ -76,7 +76,7 @@ if (OIDC_CLIENT_ID) {
);
}
const parts = profile.email.split("@");
const parts = profile.email.toLowerCase().split("@");
const domain = parts.length && parts[1];
if (!domain) {