Skip to content

fix: redirect users to correct dashboard after Google auth - #78

Merged
Smartlify07 merged 2 commits into
mainfrom
fix/google-auth-redirect
Jul 17, 2026
Merged

fix: redirect users to correct dashboard after Google auth#78
Smartlify07 merged 2 commits into
mainfrom
fix/google-auth-redirect

Conversation

@Smartlify07

@Smartlify07 Smartlify07 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

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 /login
  • auth-google-button.tsx � Changed callbackURL from /dashboard to /auth/callback
  • sidebar-navigation.tsx � Logout now navigates to /auth/signout instead of calling signOut() inline
  • (auth)/layout.tsx � Shared layout with Modern Advocates logo navbar for auth pages

Both /auth/callback and /auth/signout pages show a purple spinner with descriptive text (text-xl font-medium) and the app logo navbar.

Summary by CodeRabbit

  • New Features
    • Added streamlined authentication callback handling with role-based navigation to the admin area or dashboard.
    • Added dedicated sign-out flow with progress feedback and automatic return to the login screen.
    • Added a consistent authentication layout with a branded header and home navigation.
    • Updated Google sign-in to complete through the new authentication callback flow.
    • Updated sidebar logout navigation to use the dedicated sign-out flow.

- 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
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
modern-advocates Building Building Preview Jul 17, 2026 10:42pm

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Smartlify07, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ae32c9e9-0313-4b85-b048-c3544f37f524

📥 Commits

Reviewing files that changed from the base of the PR and between fea2666 and c4f4508.

📒 Files selected for processing (2)
  • src/app/(auth)/auth/callback/page.tsx
  • src/app/(auth)/auth/signout/page.tsx
📝 Walkthrough

Walkthrough

Authentication 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 /login. Google sign-in and sidebar logout navigation use these routes.

Changes

Authentication routing

Layer / File(s) Summary
Auth area shell
src/app/(auth)/layout.tsx
Adds a white, full-height auth layout with a home-linked logo header around child pages.
Role-based sign-in callback
src/features/auth/components/auth-google-button.tsx, src/app/(auth)/auth/callback/page.tsx
Google sign-in now targets /auth/callback; the callback waits for the session and redirects admins to /admin and other users to /dashboard.
Sign-out route flow
src/features/platform/components/sidebar-navigation.tsx, src/app/(auth)/auth/signout/page.tsx
Sidebar logout navigates to /auth/signout, which performs sign-out, displays a loading state, and redirects to /login.

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"
Loading
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"
Loading

Possibly related PRs

Poem

A rabbit hops through /auth/callback,
Roles choose their paths with cheer.
A logout page spins softly,
Then /login draws near.
Auth routes bloom—hip-hop hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the core change: Google auth now redirects users to role-appropriate destinations after sign-in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/google-auth-redirect

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 29813d9 and fea2666.

📒 Files selected for processing (5)
  • src/app/(auth)/auth/callback/page.tsx
  • src/app/(auth)/auth/signout/page.tsx
  • src/app/(auth)/layout.tsx
  • src/features/auth/components/auth-google-button.tsx
  • src/features/platform/components/sidebar-navigation.tsx

Comment thread src/app/(auth)/auth/callback/page.tsx
Comment thread src/app/(auth)/auth/callback/page.tsx Outdated
Comment thread src/app/(auth)/auth/signout/page.tsx
@Smartlify07
Smartlify07 merged commit 2ba8ebc into main Jul 17, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant