fix: jwt 콜백에서 GitHub 원본 프로필을 profile 인자로 읽도록 수정 - #100
Merged
Conversation
next-auth v4 GitHub OAuth 플로우는 원본 프로필(login, id, bio 등)을 account에 넣지 않고 jwt 콜백의 별도 인자(profile)로 전달한다 (node_modules/next-auth/core/routes/callback.js 확인). account.profile은 항상 undefined였기 때문에 token.githubId가 로그인 시점에도 채워진 적이 없었고, 그 결과 ADMIN_GITHUB_ID를 아무리 정확히 설정해도 session.isAdmin이 항상 false였다. 리팩토링 전 원본 코드에도 동일한 버그가 있었으나 관리자 판정을 session.user.email로 하던 시절엔 드러나지 않았었다. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
#99 (GitHub id 기반 관리자 판정 리팩토링)가 머지된 이후에 발견한 버그 수정 커밋을 실수로 이미 머지된 브랜치에 push하는 바람에 master에 반영이 안 됐다. 이 PR로 그 누락분을 반영한다.
문제
app/lib/auth.ts의jwt콜백이account?.profile을 읽고 있었는데, next-auth v4의 GitHub OAuth 플로우(node_modules/next-auth/core/routes/callback.js)는 원본 프로필(login,id,bio등)을account에 넣지 않고 콜백의 별도profile인자로 전달한다. 즉account.profile은 항상undefined였고,token.githubId가 로그인 시점에도 채워진 적이 없었다.그 결과
ADMIN_GITHUB_ID를 정확히 설정하고 재로그인해도session.isAdmin이 항상false였다 — #99가 도입한 관리자 판정 로직 자체가 애초에 동작하지 않는 상태였다.이 버그는 리팩토링 이전 원본 코드에도 동일하게 있었지만, 그때는 관리자 판정을
session.user.email로 했기 때문에 드러나지 않았다.수정
배포 후 필수 확인
JWT는 로그인 시점에만 갱신되므로, 배포 후 로그아웃 → GitHub 재로그인을 해야 새 토큰에
githubId가 채워지고 관리자 인식이 정상 동작한다.🤖 Generated with Claude Code