feat: detect revoked GitHub token and prompt re-authentication#1920
feat: detect revoked GitHub token and prompt re-authentication#1920Subhra-Nandi wants to merge 4 commits into
Conversation
|
@Subhra-Nandi is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
|
CI is failing because this branch is based on an older version of Please rebase on git fetch origin
git rebase origin/main
git push --force-with-lease |
adfba1b to
7f9e8a2
Compare
|
Hi @Priyanshu-byte-coder ,
No new dependencies were introduced. |
|
CI is failing because The lockfile diff shows those packages being removed while npm install
git add package-lock.json
git commit -m "fix: sync package-lock.json"
git pushThe rest of the PR (TokenRevokedGuard, signin page error message) looks correct — just need the lockfile fixed to get CI green. |
b2b1d98 to
1d2bb11
Compare
1d2bb11 to
94687d5
Compare
|
This PR has merge conflicts with git fetch origin
git rebase origin/main |
|
Hi! This PR has merge conflicts with the git fetch upstream
git rebase upstream/main
# resolve any conflicts
git push --force-with-leaseIf you're no longer working on this, let us know and we can close it. Thanks! |
|
Hi! Thanks for the heads-up. I won't be able to dedicate time to finish up the rebase or work on this feature further right now, so please feel free to close this pull request. Thanks for your time and guidance! |
|
This PR has merge conflicts with the main branch. Please rebase your branch on latest main and resolve the conflicts so it can be reviewed and merged. |
Summary
Closes #884
The JWT callback in
auth.tsalready validates the stored token every 24hand sets
session.error = "TokenRevoked"when GitHub returns 401. This PRcompletes the user-facing side — detecting that flag and redirecting the user
to sign in with a clear message instead of silently showing empty widgets.
Changes
src/app/auth/signin/page.tsxTokenRevokedtoAUTH_ERROR_MESSAGESsrc/components/TokenRevokedGuard.tsxsrc/app/dashboard/page.tsxTokenRevokedGuardpackage.jsonrehype-sanitizedependencyHow It Works
jwtcallback hitsGET /api.github.com/user→ gets 401token.error = "TokenRevoked"is set on the JWTsession.error = "TokenRevoked"is surfaced to the clientTokenRevokedGuarddetects this and callssignOut({ callbackUrl: "/auth/signin?error=TokenRevoked" })What Was Already There (untouched)
auth.ts— full token validation logic ✅next-auth.d.ts— types forsession.error✅error-utils.ts— safe error message string ✅wrapped/page.tsx— already handlesTokenRevoked✅Screenshots