fix: resolve auth flow and DB schema issues

Fix column name mismatches, enhance signup UX, and align DB schema with codebase.

Co-authored-by: Moheeb Zara <[email protected]>
This commit is contained in:
v0
2026-03-11 06:17:13 +00:00
co-authored by Moheeb Zara
parent e90e39dbbb
commit 0f71ddf377
2 changed files with 47 additions and 27 deletions
+14
View File
@@ -107,12 +107,26 @@ export default function SignupPage() {
if (authError) { setError(authError.message); setLoading(false); return }
// If Supabase returns a session immediately it means email confirmation is
// disabled — the user is fully signed up AND signed in in one step.
// We still need to create the space/member record via the server action.
if (authData.session) {
// User is now authenticated — create the space or join via server action
const result = mode === 'create'
? await createSpace({ spaceName, spaceSlug, spaceCity, displayName: fullName })
: await joinSpace({ inviteCode, displayName: fullName })
if (result.error) {
setError(result.error)
setLoading(false)
return
}
router.push('/dashboard')
router.refresh()
return
}
// Email confirmation is required — redirect to the confirm page
router.push('/signup/confirm?email=' + encodeURIComponent(email))
}
+20 -14
View File
@@ -148,11 +148,16 @@ CREATE TABLE IF NOT EXISTS public.spaces (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
name text NOT NULL,
slug text NOT NULL UNIQUE,
description text,
logo_url text,
city text,
address text,
timezone text DEFAULT 'America/Phoenix',
invite_code text,
require_approval boolean NOT NULL DEFAULT true,
public_member_directory boolean NOT NULL DEFAULT false,
invite_code text NOT NULL UNIQUE,
webhook_secret text,
settings jsonb DEFAULT '{}',
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now()
);
@@ -162,21 +167,22 @@ CREATE TABLE IF NOT EXISTS public.spaces (
CREATE TABLE IF NOT EXISTS public.space_members (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
space_id uuid NOT NULL REFERENCES public.spaces(id) ON DELETE CASCADE,
user_id uuid REFERENCES auth.users(id) ON DELETE SET NULL,
display_name text NOT NULL,
handle text,
user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
role public.member_role NOT NULL DEFAULT 'member',
tier public.member_tier NOT NULL DEFAULT 'basic',
status public.member_status NOT NULL DEFAULT 'unverified',
approved boolean NOT NULL DEFAULT true,
full_name text,
email text,
phone text,
role member_role NOT NULL DEFAULT 'member',
tier member_tier NOT NULL DEFAULT 'basic',
status member_status NOT NULL DEFAULT 'current',
approved boolean NOT NULL DEFAULT true,
has_card_access boolean NOT NULL DEFAULT false,
payment_status text,
payment_note text,
last_payment_at timestamptz,
last_paid_at timestamptz,
joined_at timestamptz NOT NULL DEFAULT now()
bio text,
avatar_url text,
joined_at timestamptz DEFAULT now(),
dues_paid_until timestamptz,
stripe_customer_id text,
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (space_id, user_id)
);
-- ── tasks ────────────────────────────────────────────────────────────────────