feat(aluno): onboarding form for real CPF + address on OAuth login#198
Conversation
Google OAuth users had no aluno row, landing on 'perfil não encontrado' empty-state. Lazy-provision on first /aluno/dashboard visit: - findUnique miss -> prisma.aluno.create with email + user_metadata (full_name, avatar_url) + deterministic CPF placeholder OAUTH-<uid14> - race guarded: concurrent-create catch refetches - same pattern applies to GitHub/Apple OAuth providers Also fix site_url fallback (was localhost, sent OAuth mismatches to localhost root with ?code=): set to production domain. Local dev still works via additional_redirect_urls localhost entry. Co-Authored-By: Claude <noreply@anthropic.com>
Replace placeholder-CPF auto-provision with redirect to /aluno/onboarding. completeOnboardingAction reads email/nome/foto from Supabase session (anti-spoof), validates via OnboardingBaseSchema with CPF check-digit verification, creates the aluno row with cep/endereco/numero/bairro/cidade/estado. Client form mirrors the schema locally; ViaCEP lookup on CEP blur with manual-entry fallback. Idempotent: P2002 race refetch by email. Schema adds 6 nullable address columns.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 18 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
✨ 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 |
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|



Summary
First Google OAuth login for a user with no
alunosrow now redirects to/aluno/onboardingto collect a real CPF + CEP + address, instead of auto-provisioning a placeholder-CPF row (OAUTH-${user.id.slice(0,18)})./aluno/dashboard: removed 60-line placeholder auto-provision block →if (!aluno) redirect('/aluno/onboarding')./aluno/onboarding(new): server gate — no session →/aluno/login, existing row →/aluno/dashboard(idempotent), else renders<OnboardingClient />.completeOnboardingAction(new server action): readsemail/nomeCompleto/fotoUrlfrom the authenticated Supabase session (not the form → anti-spoof), re-validates the payload withOnboardingBaseSchema, creates the row. OnP2002(concurrent submit race) refetches by email → surfaces success.OnboardingClient(new client form): all fields required (CPF, telefone, dataNascimento, CEP, endereco, numero, bairro, cidade, estado). Masks CPF/CEP/phone. ViaCEP lookup on CEPonBlurfills endereco/bairro/cidade/estado; onerro:trueor network failure leaves fields empty (manual-entry fallback). Schema mirrored locally to keep serverdefinitions.tsout of the browser bundle.Schema
prisma/schema.prisma— 6 nullable String columns onalunosbeforestatusMatricula:cep,endereco,numero,bairro,cidade,estado. No migration file (project usesprisma db push); cloud Supabase needs manualALTER TABLE:CPF validation
OnboardingBaseSchemavalidates format (^\d{3}\.\d{3}\.\d{3}-\d{2}$) and check digits viacpfCheckDigit()— rejects all-equal-digit patterns, computes both verifiers per the standard CPF algorithm.Tests
onboarding.test.ts— 4 tests: full-address create, no-auth error, invalid-check-digit rejection, P2002 race refetch.onboarding-client.test.tsx— 2 tests: ViaCEP fills 4 fields,erro:truefallback leaves empty.onboarding/page.test.tsx— 3 tests: redirect-to-login, redirect-to-dashboard (existing row), render-client.dashboard/page.test.tsx— updated: null-aluno →NEXT_REDIRECTto/aluno/onboarding.All 1173 tests pass, typecheck + lint green.
Carried-over
supabase/config.tomlsite_url→ production URL (auth-redirect fix; onboarding depends on OAuth redirect working).🤖 Generated with Claude Code
Summary by cubic
First OAuth login now redirects users without an
alunosrow to/aluno/onboardingto collect a real CPF and full address, replacing the placeholder-CPF auto-provision. Adds a server action to create the profile from session data with strict CPF validation and ViaCEP autofill.New Features
/aluno/dashboard: if no aluno, redirect to/aluno/onboarding(removed placeholder provision)./aluno/onboarding: guards session; skips form when a row exists; rendersOnboardingClient.completeOnboardingAction: reads email/name/photo from Supabase session, validates withOnboardingBaseSchema(CPF check digits), handlesP2002race by refetching, then revalidates the dashboard path.OnboardingClient: required fields (CPF, telefone, dataNascimento, CEP, endereço, número, bairro, cidade, estado) with masks; ViaCEP on CEP blur fills address; manual-entry fallback.supabase/config.toml: setsite_urlto production to fix OAuth redirect allowlist.Migration
alunos:cep,endereco,numero,bairro,cidade,estado. For Supabase cloud (project usesprisma db push), run ALTER TABLE to add these columns before deploying.Written for commit ac3d258. Summary will update on new commits.