Skip to content

Fix: Resolve Dual GitHub Token Storage Failures (Fixes #263)#324

Merged
indresh404 merged 1 commit into
indresh404:mainfrom
Adi-Marathe:fix-issue-263
Jun 6, 2026
Merged

Fix: Resolve Dual GitHub Token Storage Failures (Fixes #263)#324
indresh404 merged 1 commit into
indresh404:mainfrom
Adi-Marathe:fix-issue-263

Conversation

@Adi-Marathe
Copy link
Copy Markdown
Contributor

Description

This PR resolves Issue #263, where storing GitHub access tokens in two different sessionStorage keys (gh_access_token and gh_token_${uid}) resulted in severe synchronization issues, silent API failures, and misleading "rate limit" errors.

Changes Made

  1. Centralized Token Management:

    • Created a new utility file src/utils/tokenManager.js.
    • This module exposes store(), get(), remove(), and clear() methods, all using a single key format: gh_token_${uid}.
  2. Cleaned up AuthContext.jsx:

    • Removed initialization and state fallback logic dependent on gh_access_token.
    • Replaced all raw sessionStorage API calls in login and logout functions with TokenManager.
    • Logging out now clears all GitHub token variants safely.
  3. Fixed Missing Token Handling in GitRank.jsx:

    • Replaced the direct sessionStorage.getItem lookup with TokenManager.get(user?.uid).
    • Implemented an explicit guard for null tokens that displays a clear user error ("GitHub token not found. Please log in again to view your charts.") and short-circuits the API request. This prevents the misleading 401-triggered rate limit warnings.

Proof of Fix

  • No Residual Keys: Ran a repository-wide search (grep) for gh_access_token and verified 0 occurrences remain in the codebase.
  • Single Source of Truth: The pattern gh_token_ is now completely isolated within tokenManager.js.
  • Build Passing: A production build (npm run build) was successfully compiled without any errors.

Acceptance Criteria Verified

  • Removed gh_access_token key entirely.
  • All components use the new TokenManager utility.
  • Logout clears all token variants.
  • Added proper error messages for missing tokens rather than showing a "rate limit" error.

Closes: #263

@Adi-Marathe Adi-Marathe requested a review from indresh404 as a code owner June 4, 2026 11:51
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ranker-hub Ready Ready Preview, Comment Jun 6, 2026 10:14am

@github-actions github-actions Bot added backend Backend/Firebase related changes bug Something isn't working enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review labels Jun 4, 2026
@indresh404
Copy link
Copy Markdown
Owner

Fix conflict

@Adi-Marathe
Copy link
Copy Markdown
Contributor Author

Hello @indresh404
conflicts are solved

@indresh404
Copy link
Copy Markdown
Owner

If your PR still shows the old failed Vercel check, please rebase (or merge the latest main branch into your branch) and push again to trigger a fresh deployment/check run.

@Adi-Marathe
Copy link
Copy Markdown
Contributor Author

Hello @indresh404
All issues are solved now
please review it

@indresh404 indresh404 merged commit 7e7a45f into indresh404:main Jun 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend/Firebase related changes bug Something isn't working enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 level3 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Dual GitHub Token Storage Creates Auth Failures

2 participants