fix(auth): return structured token_expired 401 error and add auto-red… - #3261
Conversation
…irect prompt to components
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
|
Hi @Priyanshu-byte-coder kindly review and merge it |
|
Verified against current The best part is the Three things to resolve first. 1. The banner is unreadable in light themes. text-amber-700 dark:text-amber-300gets you 4.71:1 on light and keeps the current dark appearance. 2. The 3-second auto-redirect. 3. Also: the client checks for Fix those and I'll merge it. |
Summary
Gracefully handles expired or revoked GitHub OAuth tokens across API route handlers (
/api/metrics/*) by returning structured 401 JSON responses ({ error: "token_expired" }). Dashboard components detect token expiration, display a "Session expired — please sign in again" banner, and auto-redirect to/api/auth/signinafter 3 seconds.Closes #3244
Type of Change
What Changed
src/lib/github-fetch.ts: ReturnsGitHubAuthErroron HTTP 401 responses.src/app/api/metrics/contributions/route.ts&src/app/api/metrics/prs/route.ts: ReturnsgithubAuthErrorResponse()(HTTP 401{ error: "token_expired" }) when authentication is invalid or revoked.src/components/ContributionGraph.tsx: Catches 401token_expirederrors, shows a session expiration banner, and auto-redirects to/api/auth/signinafter 3 seconds.How to Test
/api/auth/signinafter 3 seconds.Checklist
console.logor debug code