fix(web): redirect to OAuth authorize page after login instead of /apps#32177
fix(web): redirect to OAuth authorize page after login instead of /apps#32177RockChinQ merged 1 commit intofeat/support-agent-sandboxfrom
Conversation
After social auth (GitHub/Google), the backend redirects to the root page `/` which was a static server component showing only a loading spinner. The pending OAuth authorize URL stored in localStorage was never consumed, causing users to get stuck instead of returning to the OAuth authorization flow. Convert root page to a client component that checks localStorage for a pending OAuth redirect on mount and navigates accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @RockChinQ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the social authentication flow where users were not correctly redirected to the OAuth authorization page after logging in. By transforming the root page into a client-side component, the application can now properly detect and utilize stored OAuth redirect URLs, ensuring a seamless and functional authentication experience. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to resolve the issue of users getting stuck after social authentication by implementing a client-side redirect from the root page. However, it introduces a potential Open Redirect vulnerability because the redirect target from localStorage is not validated before use. Additionally, an improvement is needed in the useEffect hook in web/app/page.tsx to align with Next.js best practices.
| const pendingRedirect = getOAuthPendingRedirect(OAUTH_AUTHORIZE_PENDING_KEY) | ||
| if (pendingRedirect) { | ||
| router.replace(pendingRedirect) |
There was a problem hiding this comment.
The application retrieves a redirect URL from localStorage and passes it directly to router.replace() without validation. This introduces a potential Open Redirect vulnerability, allowing an attacker to redirect users to a malicious external website. The provided suggestion validates that pendingRedirect is a safe, internal path (e.g., starts with a single / and not //). Additionally, the useEffect dependency array includes router, which is not guaranteed to be stable; for an effect that should run once on mount, an empty dependency array [] is recommended for useEffect.
| const pendingRedirect = getOAuthPendingRedirect(OAUTH_AUTHORIZE_PENDING_KEY) | |
| if (pendingRedirect) { | |
| router.replace(pendingRedirect) | |
| const pendingRedirect = getOAuthPendingRedirect(OAUTH_AUTHORIZE_PENDING_KEY) | |
| if (pendingRedirect && pendingRedirect.startsWith('/') && !pendingRedirect.startsWith('//')) { | |
| router.replace(pendingRedirect) | |
| return | |
| } |
After social auth (GitHub/Google), the backend redirects to the root page
/which was a static server component showing only a loading spinner. The pending OAuth authorize URL stored in localStorage was never consumed, causing users to get stuck instead of returning to the OAuth authorization flow.Convert root page to a client component that checks localStorage for a pending OAuth redirect on mount and navigates accordingly.
Important
Fixes #<issue number>.Summary
Screenshots
Checklist
make lintandmake type-check(backend) andcd web && npx lint-staged(frontend) to appease the lint gods