From 098e0aac56828933347da4c5397652b2177060fb Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Tue, 9 Sep 2025 17:30:27 +0700 Subject: [PATCH] :bug: (fix) handle user name not found Handle users who do not have a name by entering the login field as the username field to prevent errors in the GitHub provision account process. --- src/modules/auth/auth.types.ts | 20 +++++++++---------- .../services/http/githubCallback.service.ts | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/modules/auth/auth.types.ts b/src/modules/auth/auth.types.ts index 98060e7..50f74e7 100644 --- a/src/modules/auth/auth.types.ts +++ b/src/modules/auth/auth.types.ts @@ -32,15 +32,15 @@ interface GithubUserData { type: string; user_view_type: string; site_admin: boolean; - name: string; - company: null; - blog: string; - location: string; - email: null; - hireable: null; - bio: string; - twitter_username: null; - notification_email: null; + name?: string; + company?: string; + blog?: string; + location?: string; + email?: string; + hireable?: boolean; + bio?: string; + twitter_username?: string; + notification_email?: string; public_repos: number; public_gists: number; followers: number; @@ -52,5 +52,5 @@ interface GithubUserEmail { email: string; primary: boolean; verified: boolean; - visibility: null | string; + visibility?: string; } diff --git a/src/modules/auth/services/http/githubCallback.service.ts b/src/modules/auth/services/http/githubCallback.service.ts index fae469e..1c19e92 100644 --- a/src/modules/auth/services/http/githubCallback.service.ts +++ b/src/modules/auth/services/http/githubCallback.service.ts @@ -45,7 +45,7 @@ export const githubCallbackService = async ( userPayload.user_email.find((email) => email.primary === true) ?.email || userPayload.user_email[0].email, username: `git_${userPayload.user_data.id}`, - name: userPayload.user_data.name, + name: userPayload.user_data.name ?? userPayload.user_data.login, avatar: userPayload.user_data.avatar_url, password: Math.random() .toString(36)