feat: add basic sign up flow #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "add-basic-sign-up-flow"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
File:
supabase/migrations/20251121133948_replace_auth_trigger_with_signup_rpc.sqlActionable change: Do NOT add
auth_user_id uuid not nullin one step on a populated table. Change migration to: (1) addauth_user_id uuid NULL, (2) backfill values for existing rows (or create matchingauth.userstest rows in seed), (3) add FK andNOT NULLconstraint in a subsequent migration. CurrentALTER TABLE ... ADD COLUMN ... NOT NULLwill fail on non-empty DBs.Also: the migration adds a FK/unique and then validates constraint — ensure ordering after backfill so
validate constraintwon't fail.Please split this migration and add a short comment in the file describing the multi-step plan so reviewers/CI understand the intended rollout.
File:
supabase/migrations/20251121145635_add_validate_invite_function.sqlActionable change: Remove
pg_sleep(5)fromvalidate_invite_code. Sleeping inside DB functions ties up Postgres worker processes and risks resource exhaustion under load. Alternatives:Actionable change: Avoid returning the invitee
namefrom this RPC (it leaks information about existing members). Return only a minimal response (e.g.{ valid: true }) or a masked value if necessary.Changes Requested
Please address the following high-impact items before merging:
auth_user_idrollout: add nullable column, backfill existing rows (or seed matchingauth.users), then add FK/unique + set NOT NULL in a follow-up migration. Include comments describing the multi-step rollout.pg_sleep(5)fromvalidate_invite_codeandcomplete_signup. Implement rate-limiting at the edge/app layer or use a non-blocking DB pattern (attempts table / atomic counter) instead.name(or any identifying data) fromvalidate_invite_code; return a minimal validation response only.src/middleware.ts: definecookieHeaderfrom request headers before creating the server Supabase client, only call RPCs whenuserexists, and wrap RPC calls in try/catch with graceful handling (redirect to/auth/welcomeor allow limited access).npmscripts inpackage.json(or addnpmproxies tojust) so contributors and tools that expectnpm runcontinue to work.Summary of Changes
OnboardingWizard,ErrorAlert, refactorsButtonwith forwardRef).validate_invite_code,complete_signup,get_user_by_auth_id.auth_user_idtousertable and updates seeds to create user/contact rows manually (migration currently makes column NOT NULL + FK in one step).just(addsjustfile), updates CI to calljust, and removesnpmscripts frompackage.json.Overall Feedback
Negative: There are critical operational/security risks in the DB changes and RPCs that must be fixed before merging. Adding a NOT NULL FK column on a populated table and using
pg_sleep()inside Postgres functions will break production rollouts and can lead to resource exhaustion. Returning invitee names from an early validation RPC leaks membership info. The middleware currently relies on an undefinedcookieHeaderand calls RPCs unconditionally which can throw in middleware.Positive: The frontend onboarding UX and component refactors are well-organized and improve developer ergonomics. Moving to explicit RPCs and deterministic seeds is the right direction when migrations and rate-limiting are implemented safely. Documentation and CI improvements show good attention to DX. Nice work on the UI polish and separation of concerns!
Please @Pertempto when you push the updates and request another review. Thank you! :)
File:
supabase/schemas/02_users.sqlActionable change (migration safety): The schema now declares
auth_user_id uuid unique not null references auth.users(id)directly. For production rollout, do NOT add a NOT NULL FK column in one step on populated tables. Instead:auth_user_id uuidnullable first,auth.usersentries),NOT NULLconstraint in a subsequent migration.Actionable change (consistency): Remove duplicate index creation — you create
idx_user_auth_user_idhere and also in the migration file. Keep index creation in migrations only to avoid schema drift.Please update the schema/migrations to a safe, multi-step rollout.
File:
src/middleware.tsget_user_by_auth_idRPC before ensuring the request is authenticated and before consistently passing request cookies tocreateSupabaseServerClient.createSupabaseServerClient(context.cookies, cookieHeader)(you already added that param in import but must ensure it's used everywhere consistently).get_user_by_auth_idRPC whenuseris present; check foruserfirst. If the RPC fails, handle the error gracefully and avoid leaking internal errors — return a server-side redirect to/auth/welcomeor let the request proceed with limited access.Please reorder logic so authentication is checked first, then create the server client with request cookies, then call the RPC. Add error handling around the RPC (try/catch) and log fewer internal details in production.