-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: add authentication token to repository fetch requests #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
👋 Thanks for opening this pull request! A maintainer will review it soon. Please make sure all CI checks pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds client-side authentication to the repositories fetch call so the backend receives an auth token when listing GitHub repositories.
Changes:
- Read
accessTokenfromlocalStoragebefore fetching repositories - Short-circuit the fetch with a “Not authenticated” error when no token is present
- Add
Authorization: Bearer <token>header to the repositories request
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if (!token) { | ||
| setLoading(false); | ||
| setError('Not authenticated'); |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When no token is present you early-return after setting an error, but you leave the existing repositories state untouched. If a user previously loaded repos and then logs out/loses the token, consumers could still see stale data. Consider clearing repositories (e.g., setRepositories([])) when setting the unauthenticated error.
| setError('Not authenticated'); | |
| setError('Not authenticated'); | |
| setRepositories([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/hooks/useRepositories.tsx`:
- Around line 29-35: The hook useRepositories currently returns early when token
is missing but leaves previously loaded data visible; update the auth-failure
path to clear stale repo state by calling setRepositories([]) (and any related
pagination flags like setHasMore(false) if present) before setting
setLoading(false) and setError('Not authenticated'), so when token is removed
the UI no longer shows private/stale repository data.
| const token = localStorage.getItem('accessToken'); | ||
|
|
||
| if (!token) { | ||
| setLoading(false); | ||
| setError('Not authenticated'); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clear repositories on missing token to avoid stale/private data.
If a token disappears after data was loaded (logout/expiry), the hook keeps showing the previous list. Consider clearing state on the auth-failure path.
🔧 Proposed fix
if (!token) {
+ setRepositories([]);
setLoading(false);
setError('Not authenticated');
return;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const token = localStorage.getItem('accessToken'); | |
| if (!token) { | |
| setLoading(false); | |
| setError('Not authenticated'); | |
| return; | |
| } | |
| const token = localStorage.getItem('accessToken'); | |
| if (!token) { | |
| setRepositories([]); | |
| setLoading(false); | |
| setError('Not authenticated'); | |
| return; | |
| } |
🤖 Prompt for AI Agents
In `@src/hooks/useRepositories.tsx` around lines 29 - 35, The hook useRepositories
currently returns early when token is missing but leaves previously loaded data
visible; update the auth-failure path to clear stale repo state by calling
setRepositories([]) (and any related pagination flags like setHasMore(false) if
present) before setting setLoading(false) and setError('Not authenticated'), so
when token is removed the UI no longer shows private/stale repository data.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.