Skip to content

fix(auth): bounce signed-in users off sign-in page (mobile Back) - #121

Merged
TechHypeXP merged 1 commit into
mainfrom
claude/signin-back-guard
Jul 6, 2026
Merged

fix(auth): bounce signed-in users off sign-in page (mobile Back)#121
TechHypeXP merged 1 commit into
mainfrom
claude/signin-back-guard

Conversation

@TechHypeXP

@TechHypeXP TechHypeXP commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Problem (from live mobile testing)

On mobile (Samsung), the device Back button "simply takes you to the sign-in screen" — a dead end for a logged-in user.

Root cause

Sign-in is a full-page OAuth redirect (signInWithOAuth → Google → /auth/callback → app), so /auth/signin stays on the browser history stack. Pressing Back pops to it. The sign-in page had no auth guard, so it just rendered the sign-in form again even though the user is already authenticated.

Fix

Guard the sign-in server component: if a session already exists (loadConsoleProfile() — the app's existing auth gate), redirect() into the app instead of rendering the form. So Back → /auth/signin → immediate forward-redirect to the console, which is the behavior a user expects.

  • Honours a safe app-internal ?next (only /-prefixed, non-// targets) else /dashboard — no open-redirect surface.
  • export const dynamic = 'force-dynamic' so the guard runs per request.

Covers task #51.

Verification

  • tsc --noEmit: clean
  • qa-intel (full ruleset): no issues

🤖 Generated with Claude Code


Generated by Claude Code


Summary by cubic

Redirects already-signed-in users away from /auth/signin so the mobile Back button doesn’t trap them on the sign-in screen after OAuth. Addresses Linear #51.

  • Bug Fixes
    • Added server-side guard on /auth/signin: if loadConsoleProfile() finds a session, call redirect() to ?next or /dashboard.
    • Validates ?next as app-internal (starts with /, not //) to prevent open redirects.
    • Sets export const dynamic = 'force-dynamic' to run the guard on every request.

Written for commit c3aeba6. Summary will update on new commits.

Review in cubic

On mobile the device Back button pops history to /auth/signin — the
OAuth sign-in flow leaves that route on the stack — so an authenticated
user pressing Back dead-ended on the sign-in screen. Guard the sign-in
page: if a session already exists, redirect into the app (honouring a
safe app-internal ?next, else /dashboard), so Back effectively returns to
the console instead. Open-redirect-safe: only '/'-prefixed, non-'//'
targets are honoured.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ByQJWuMebsKpQcHNqXCBWD
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hex-yt-intel Ready Ready Preview, Comment Jul 6, 2026 11:11am

@sourcery-ai sourcery-ai 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.

Sorry @TechHypeXP, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@supabase

supabase Bot commented Jul 6, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project adnmbikaqnxivalqoild because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next review available in: 12 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: ASSERTIVE

Plan: Pro

Run ID: a26848e8-770a-49c9-9538-9eea7f66160c

📥 Commits

Reviewing files that changed from the base of the PR and between e4aedac and c3aeba6.

📒 Files selected for processing (1)
  • web/app/auth/signin/page.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/signin-back-guard
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/signin-back-guard

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.

@deepsource-io

deepsource-io Bot commented Jul 6, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in e4aedac...c3aeba6 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Jul 6, 2026 11:10a.m. Review ↗
Shell Jul 6, 2026 11:10a.m. Review ↗
Secrets Jul 6, 2026 11:10a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

if (profile) {
const { next } = await searchParams;
// Only honour app-internal paths to avoid an open-redirect via ?next=.
const dest = next && next.startsWith('/') && !next.startsWith('//') ? next : '/dashboard';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer using an optional chain expression instead, as it's more concise and easier to read


The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Pipeline Status: All checks passed. Ready to merge.

@TechHypeXP
TechHypeXP merged commit 186851c into main Jul 6, 2026
27 of 28 checks passed
TechHypeXP added a commit that referenced this pull request Jul 31, 2026
…121)

On mobile the device Back button pops history to /auth/signin — the
OAuth sign-in flow leaves that route on the stack — so an authenticated
user pressing Back dead-ended on the sign-in screen. Guard the sign-in
page: if a session already exists, redirect into the app (honouring a
safe app-internal ?next, else /dashboard), so Back effectively returns to
the console instead. Open-redirect-safe: only '/'-prefixed, non-'//'
targets are honoured.


Claude-Session: https://claude.ai/code/session_01ByQJWuMebsKpQcHNqXCBWD

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants