fix: profile.name is not mandatory anymore in OIDC provder

This commit is contained in:
Tom Moor
2023-04-12 21:59:24 -04:00
parent 511e790cb1
commit 821c9368f6

View File

@@ -94,11 +94,6 @@ if (
`An email field was not returned in the profile parameter, but is required.`
);
}
if (!profile.name) {
throw AuthenticationError(
`A name field was not returned in the profile parameter, but is required.`
);
}
const team = await getTeamFromContext(ctx);
const client = getClientFromContext(ctx);
@@ -115,6 +110,13 @@ if (
// Claim name can be overriden using an env variable.
// Default is 'preferred_username' as per OIDC spec.
const username = get(profile, env.OIDC_USERNAME_CLAIM);
const name = profile.name || username || profile.username;
if (!name) {
throw AuthenticationError(
`Neither a name or username was returned in the profile parameter, but at least one is required.`
);
}
const result = await accountProvisioner({
ip: ctx.ip,
@@ -126,7 +128,7 @@ if (
subdomain,
},
user: {
name: profile.name || username || profile.username,
name,
email: profile.email,
avatarUrl: profile.picture,
},