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:
@@ -107,12 +107,26 @@ export default function SignupPage() {
|
|||||||
|
|
||||||
if (authError) { setError(authError.message); setLoading(false); return }
|
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) {
|
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.push('/dashboard')
|
||||||
router.refresh()
|
router.refresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Email confirmation is required — redirect to the confirm page
|
||||||
router.push('/signup/confirm?email=' + encodeURIComponent(email))
|
router.push('/signup/confirm?email=' + encodeURIComponent(email))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+33
-27
@@ -145,38 +145,44 @@ $$;
|
|||||||
-- ── spaces ───────────────────────────────────────────────────────────────────
|
-- ── spaces ───────────────────────────────────────────────────────────────────
|
||||||
-- Top-level tenant. Each hackerspace is one row.
|
-- Top-level tenant. Each hackerspace is one row.
|
||||||
CREATE TABLE IF NOT EXISTS public.spaces (
|
CREATE TABLE IF NOT EXISTS public.spaces (
|
||||||
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||||
name text NOT NULL,
|
name text NOT NULL,
|
||||||
slug text NOT NULL UNIQUE,
|
slug text NOT NULL UNIQUE,
|
||||||
city text,
|
description text,
|
||||||
require_approval boolean NOT NULL DEFAULT true,
|
logo_url text,
|
||||||
public_member_directory boolean NOT NULL DEFAULT false,
|
city text,
|
||||||
invite_code text NOT NULL UNIQUE,
|
address text,
|
||||||
webhook_secret text,
|
timezone text DEFAULT 'America/Phoenix',
|
||||||
created_at timestamptz NOT NULL DEFAULT now(),
|
invite_code text,
|
||||||
updated_at timestamptz NOT NULL DEFAULT now()
|
require_approval boolean NOT NULL DEFAULT true,
|
||||||
|
public_member_directory boolean NOT NULL DEFAULT false,
|
||||||
|
webhook_secret text,
|
||||||
|
settings jsonb DEFAULT '{}',
|
||||||
|
created_at timestamptz NOT NULL DEFAULT now(),
|
||||||
|
updated_at timestamptz NOT NULL DEFAULT now()
|
||||||
);
|
);
|
||||||
|
|
||||||
-- ── space_members ─────────────────────────────────────────────────────────────
|
-- ── space_members ─────────────────────────────────────────────────────────────
|
||||||
-- One row per (user × space). A user may belong to multiple spaces.
|
-- One row per (user × space). A user may belong to multiple spaces.
|
||||||
CREATE TABLE IF NOT EXISTS public.space_members (
|
CREATE TABLE IF NOT EXISTS public.space_members (
|
||||||
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||||
space_id uuid NOT NULL REFERENCES public.spaces(id) ON DELETE CASCADE,
|
space_id uuid NOT NULL REFERENCES public.spaces(id) ON DELETE CASCADE,
|
||||||
user_id uuid REFERENCES auth.users(id) ON DELETE SET NULL,
|
user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
|
||||||
display_name text NOT NULL,
|
role public.member_role NOT NULL DEFAULT 'member',
|
||||||
handle text,
|
tier public.member_tier NOT NULL DEFAULT 'basic',
|
||||||
email text,
|
status public.member_status NOT NULL DEFAULT 'unverified',
|
||||||
phone text,
|
approved boolean NOT NULL DEFAULT true,
|
||||||
role member_role NOT NULL DEFAULT 'member',
|
full_name text,
|
||||||
tier member_tier NOT NULL DEFAULT 'basic',
|
email text,
|
||||||
status member_status NOT NULL DEFAULT 'current',
|
phone text,
|
||||||
approved boolean NOT NULL DEFAULT true,
|
bio text,
|
||||||
has_card_access boolean NOT NULL DEFAULT false,
|
avatar_url text,
|
||||||
payment_status text,
|
joined_at timestamptz DEFAULT now(),
|
||||||
payment_note text,
|
dues_paid_until timestamptz,
|
||||||
last_payment_at timestamptz,
|
stripe_customer_id text,
|
||||||
last_paid_at timestamptz,
|
created_at timestamptz NOT NULL DEFAULT now(),
|
||||||
joined_at timestamptz NOT NULL DEFAULT now()
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||||
|
UNIQUE (space_id, user_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- ── tasks ────────────────────────────────────────────────────────────────────
|
-- ── tasks ────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user