fix(account): handle single-word names in OIDC and GitHub auth providers (#10631)

When a user's name has no spaces (common for CJK names like "西门吹雪"),
name.split(' ') returns a single-element array so the last name
destructures as undefined, causing a PostgreSQL NOT NULL constraint
violation on the last_name column.

- openid: prefer standard OIDC given_name/family_name claims when
  available, fall back to splitting name with safe slice(1).join()
- github: same split fix using displayName ?? username
- loginOrSignUpWithProvider: add ?? '' defensive fallback at insertOne
  to guard against any undefined last name reaching the DB

Fixes #10628

Signed-off-by: SaiVaraprasad Medapati <varaprasadreddy9676@gmail.com>
This commit is contained in:
SaiVaraprasad Medapati
2026-03-18 14:37:14 +07:00
committed by GitHub
parent f4cfa3c609
commit 577f0aa8a2
3 changed files with 7 additions and 3 deletions
+3 -1
View File
@@ -57,7 +57,9 @@ export function registerGithub (
},
async (ctx, next) => {
const email = ctx.state.user.emails?.[0]?.value
const [first, last] = ctx.state.user.displayName?.split(' ') ?? [ctx.state.user.username, '']
const nameParts = (ctx.state.user.displayName ?? ctx.state.user.username ?? '').split(' ')
const first: string = nameParts[0] ?? ''
const last: string = nameParts.slice(1).join(' ')
const db = await dbPromise
const redirectUrl = await handleProviderAuth(
+3 -1
View File
@@ -87,7 +87,9 @@ export function registerOpenid (
async (ctx, next) => {
const email = ctx.state.user.email
const verifiedEmail = (ctx.state.user.email_verified as boolean) ? email : ''
const [first, last] = ctx.state.user.name?.split(' ') ?? [ctx.state.user.username, '']
const nameParts = (ctx.state.user.name ?? ctx.state.user.username ?? '').split(' ')
const first: string = ctx.state.user.given_name ?? nameParts[0] ?? ''
const last: string = ctx.state.user.family_name ?? nameParts.slice(1).join(' ')
const db = await dbPromise
const redirectUrl = await handleProviderAuth(
+1 -1
View File
@@ -1547,7 +1547,7 @@ export async function loginOrSignUpWithProvider (
return null
}
personUuid = await db.person.insertOne({ firstName: first, lastName: last })
personUuid = await db.person.insertOne({ firstName: first, lastName: last ?? '' })
}
if (personUuid == null) {