fix: redirect users to correct dashboard after Google auth - #78
Conversation
- Add /auth/callback page that checks user role and redirects to /admin or /dashboard - Add /auth/signout page with loading state before redirecting to /login - Update Google OAuth callbackURL to /auth/callback - Update admin sidebar logout to navigate to /auth/signout - Add (auth) layout with Modern Advocates logo navbar
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAuthentication now includes a shared auth layout, a session-aware callback that routes by role, and a sign-out page that completes logout before redirecting to ChangesAuthentication routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant AuthGoogleButton
participant AuthCallbackPage
participant authClient
participant NextRouter
AuthGoogleButton->>AuthCallbackPage: callbackURL "/auth/callback"
AuthCallbackPage->>authClient: useSession()
authClient-->>AuthCallbackPage: session and role
AuthCallbackPage->>NextRouter: push "/admin" or "/dashboard"
sequenceDiagram
participant SidebarNavigation
participant SignOutPage
participant authClient
participant NextRouter
SidebarNavigation->>SignOutPage: push "/auth/signout"
SignOutPage->>authClient: signOut()
authClient-->>SignOutPage: sign-out complete
SignOutPage->>NextRouter: push "/login"
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/`(auth)/auth/callback/page.tsx:
- Around line 14-15: Update the redirect in the authentication callback effect
to use router.replace instead of router.push, preserving the existing role-based
destinations and dependency list so /auth/callback is replaced rather than added
to browser history.
- Around line 12-15: Update the useEffect callback to handle the resolved
unauthenticated state: after isPending is false and session is null, redirect to
/login or show an actionable error state instead of returning indefinitely.
Preserve the existing admin and dashboard redirects for authenticated sessions,
and keep the dependency array synchronized with any referenced symbols.
In `@src/app/`(auth)/auth/signout/page.tsx:
- Around line 11-17: Update the signOut function in the useEffect hook to wrap
authClient.signOut() in a try/finally block, keeping router.push("/login") in
the finally block so redirection always occurs even when sign-out fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c1c5a134-ab9c-49da-8042-74cea0b5e94a
📒 Files selected for processing (5)
src/app/(auth)/auth/callback/page.tsxsrc/app/(auth)/auth/signout/page.tsxsrc/app/(auth)/layout.tsxsrc/features/auth/components/auth-google-button.tsxsrc/features/platform/components/sidebar-navigation.tsx
…rap signOut in try/finally
Summary
Fixes the Google OAuth redirect to send users to the correct dashboard based on their role, matching the behavior of the email OTP flows.
Changes
/auth/callback� New page that checks the user's session role after Google OAuth and redirects admins to/admin, regular users to/dashboard/auth/signout� New dedicated sign-out page showing "Logging out..." with a spinner before redirecting to/loginauth-google-button.tsx� ChangedcallbackURLfrom/dashboardto/auth/callbacksidebar-navigation.tsx� Logout now navigates to/auth/signoutinstead of callingsignOut()inline(auth)/layout.tsx� Shared layout with Modern Advocates logo navbar for auth pagesBoth
/auth/callbackand/auth/signoutpages show a purple spinner with descriptive text (text-xl font-medium) and the app logo navbar.Summary by CodeRabbit