Skip to content

Commit 9d02aab

Browse files
committed
refactor: 이메일을 받지 못했을 때 클라이언트로 에러 코드 알려주도록 개선
1 parent a619ac8 commit 9d02aab

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Firebase/functions/src/auth/github.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface GitHubEmail {
2626
verified: boolean;
2727
}
2828

29+
const GITHUB_EMAIL_UNAVAILABLE_REASON = "email_not_found";
30+
2931
// GitHub OAuth 인증 및 커스텀 토큰 발급 함수
3032
export const requestGithubTokens = onCall({
3133
cors: true,
@@ -75,7 +77,11 @@ export const requestGithubTokens = onCall({
7577
const email = await resolveGitHubEmail(accessToken, userData.email);
7678

7779
if (!userData.id || !email) {
78-
throw new HttpsError('internal', 'GitHub 사용자 데이터를 가져오지 못했습니다.');
80+
throw new HttpsError(
81+
'internal',
82+
'GitHub 사용자 데이터를 가져오지 못했습니다.',
83+
{ reason: GITHUB_EMAIL_UNAVAILABLE_REASON }
84+
);
7985
}
8086

8187
// 3. Firebase에서 GitHub 제공자로 사용자를 찾거나 생성
@@ -106,6 +112,9 @@ export const requestGithubTokens = onCall({
106112
};
107113
} catch (error) {
108114
console.error('GitHub 커스텀 토큰 생성 오류:', error);
115+
if (error instanceof HttpsError) {
116+
throw error;
117+
}
109118
throw new HttpsError('internal', error instanceof Error ? error.message : '알 수 없는 오류가 발생했습니다.');
110119
}
111120
});

0 commit comments

Comments
 (0)