Skip to content

fix(auth): restore SessionProvider in [lang]/layout#10

Open
abdout wants to merge 1 commit into
mainfrom
fix/auth-restore-session-provider
Open

fix(auth): restore SessionProvider in [lang]/layout#10
abdout wants to merge 1 commit into
mainfrom
fix/auth-restore-session-provider

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented Apr 25, 2026

Summary

  • `SessionProvider` and the `auth()` call were commented out in the locale layout → every client `useSession()` returned `unauthenticated`, breaking 6 components (`useCurrentUser`, `useCurrentRole`, ``, header avatar, pricing role form, delete-account modal).
  • Restores the wrapper. Calls `auth()` and `params` in parallel via `Promise.all` to avoid sequencing the two awaits.
  • Leaves `pages: { signIn: "/login" }` as-is — `proxy.ts` already locale-prefixes redirects on the next request, so static `/login` becomes `/{locale}/login` by cookie/Accept-Language match.

Changes

  • `src/app/[lang]/layout.tsx` — uncommented `SessionProvider` + `auth` import; wrapped children; parallel awaits.

Test plan

  • Sign in via credentials on `/en/login` → header avatar shows the user
  • Sign in via Google OAuth on `/ar/login` → redirected to `/ar`, avatar shows
  • `<RoleGate allowedRole="USER">` renders for signed-in user
  • `useCurrentUser()` returns the user object in pricing modals
  • `pnpm build` succeeds

Closes #9

🤖 Generated with Claude Code

Without SessionProvider, every client useSession() returned
unauthenticated regardless of server-side state — breaking
useCurrentUser, useCurrentRole, RoleGate, user-button avatar,
pricing role/delete forms.

Restores the wrapper at the layout level. The server layout calls
auth() once in parallel with params resolution (Promise.all), and
passes the session to SessionProvider for client descendants.

The pages: { signIn, error } config in src/auth.ts is left as-is —
proxy.ts already prefixes the user's locale on the next request after
the redirect, so /login lands on /{locale}/login by cookie.

Closes #9

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

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

Project Deployment Actions Updated (UTC)
marketing Ready Ready Preview, Comment Apr 25, 2026 8:37am

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.

fix(auth): restore SessionProvider in [lang]/layout — useSession() returns unauthenticated for all client components

1 participant