Skip to content

fix(register): preserve ?redirect= through cross-origin sign-in flows#48

Merged
amrtgaber merged 1 commit into
mainfrom
fix/register-preserve-redirect
May 27, 2026
Merged

fix(register): preserve ?redirect= through cross-origin sign-in flows#48
amrtgaber merged 1 commit into
mainfrom
fix/register-preserve-redirect

Conversation

@amrtgaber
Copy link
Copy Markdown
Contributor

Closes #47. Three small changes that mirror how `/login` already handles `?redirect=`.

Symptom

A new user clicking through from a consumer app (e.g. `hera-streamer-invitational-2026.criticalbit.gg`) lands at `auth.criticalbit.gg/login?redirect=https://hera-…/\`, sees "Don't have an account? Sign up", clicks, registers, and ends up at `/profile` instead of being bounced back to the consumer app.

Fix

  1. `login-page.tsx` Sign-up Link — pass `search={redirect ? { redirect } : {}}` so the query param survives the click.
  2. `routes/register.tsx` — add `validateSearch` for the redirect param, matching `/login`'s shape.
  3. `register-page.tsx` — after the auto-login + `auth.checkAuth()`, route to the redirect target with the same cross-origin (`window.location.href`) vs in-app (`navigate`) split that `login-page.tsx` uses.

Test plan

Adjacent

Issue #46 (display-name suggestions) covers the new-user-from-consumer-app flow at the UX level. With #47 + #46 both shipped, the flow feels right end-to-end: redirect preserved, optional name field at register, nudge on /profile if skipped.

…#47)

When a new user clicked through from a consumer app (e.g.
hera-streamer-…/) to auth.criticalbit.gg/login?redirect=…, clicking
"Don't have an account? Sign up" dropped the redirect param. After
registration they landed on /profile instead of bouncing back to the
consumer app.

Three small changes, mirroring how /login already handles redirect:

- login-page.tsx Sign-up Link passes `search={redirect ? { redirect } : {}}`
  so the query param survives the hop.
- routes/register.tsx adds `validateSearch` for the redirect param.
- register-page.tsx reads the param after auto-login and routes to it
  with the same cross-origin (window.location.href) vs in-app
  (navigate) split that login-page uses.

Closes #47.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

Deploy Preview for criticalbit-auth-web ready!

Name Link
🔨 Latest commit 6e1dcc7
🔍 Latest deploy log https://app.netlify.com/projects/criticalbit-auth-web/deploys/6a16782d2ad65e0008979e7b
😎 Deploy Preview https://deploy-preview-48--criticalbit-auth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@amrtgaber amrtgaber merged commit 40aa5c4 into main May 27, 2026
6 checks passed
@amrtgaber amrtgaber deleted the fix/register-preserve-redirect branch May 27, 2026 04:53
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.

/register drops the ?redirect= param from cross-origin sign-in flows

1 participant