Skip to content

Pro access tier: full app features, no backend#64

Merged
demilt11-lab merged 1 commit into
mainfrom
claude/publisting-audit-hardening-ixpwf6
Jul 23, 2026
Merged

Pro access tier: full app features, no backend#64
demilt11-lab merged 1 commit into
mainfrom
claude/publisting-audit-hardening-ixpwf6

Conversation

@demilt11-lab

Copy link
Copy Markdown
Owner

Adds a real, grantable Pro tier between regular users and admins — full access to every app feature, no backend/admin reach. This is the prerequisite for later demoting a full-access account from admin → pro. The tier hierarchy (admin > pro > beta > anonymous) already existed in useFeatureFlags but "pro" was unreachable; this makes it real.

Design

Pro grants no new database privileges — every Pro feature (Catalog Analysis, AI Lab, AI/ML recommendations, Reports, Teams collaboration) is already reachable by any authenticated user at the data layer; only the frontend gated it. So Pro is a pure UI-tier: a role the UI reads to decide what to show. /admin/* stays admin-only.

Backend (migrations, already applied to prod, versions reconciled)

  • app_role gains 'pro' (its own migration — enum values can't be used in the transaction that adds them).
  • pro_email_allowlist (admin-managed, RLS) + handle_new_user auto-grants Pro on sign-in for allowlisted emails (survives Google/provider switches, mirroring admin).
  • admin_set_pro(email, enabled) SECURITY DEFINER RPC keeps allowlist + user_roles in sync; admin-gated, anon EXECUTE revoked. Verified live: authenticated can execute, anon cannot.

Frontend

  • useAccessTier() resolves admin/pro/beta/anonymous from user_roles — the single source for feature gating (useIsAdmin stays the narrow admin check for backend gates + MFA step-up).
  • useFeatureFlags consumes the real tier; the 4 premium features move admin → pro.
  • AdminGate gains requirePro (admins included; no MFA step-up since Pro isn't backend). /catalog-analysis and /reports become Pro features; LeftNav items and the Index Teams section unlock for Pro.
  • Admin → Roles: per-user Make/Revoke Pro (Pro badge + count); Settings shows the account plan.

fmmusic821

Pre-seeded into the Pro allowlist and granted Pro while keeping admin, so a later admin-revoke leaves Pro in place with no access gap. Verified live: the account holds both pro and admin.

Verification

tsc -b clean · ESLint 0/0 · 362 tests green (new access-tier.test.ts + expanded admin-gate.test.tsx with Pro cases) · production build succeeds · migrations applied + verified live.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CN6KKo8XyF2N2wBLxno24C


Generated by Claude Code

Adds a real, grantable "Pro" access tier between regular users and admins,
so a full-access account can use every app feature without any backend/admin
reach. The tier hierarchy (admin > pro > beta > anonymous) already existed in
useFeatureFlags but "pro" was unreachable — this makes it real.

Backend (migrations, applied to prod):
- app_role gains 'pro' (own migration; enum values can't be used in the txn
  that adds them).
- pro_email_allowlist (admin-managed, RLS) + handle_new_user auto-grants Pro
  on sign-in for allowlisted emails (survives provider switches, like admin).
- admin_set_pro(email, enabled) SECURITY DEFINER RPC keeps the allowlist and
  the user_roles grant in sync; admin-gated, anon EXECUTE revoked.
- Pro grants NO new DB privileges: every Pro feature is already reachable by
  authenticated users at the data layer, so this is a pure UI-tier.

Frontend:
- useAccessTier() resolves admin/pro/beta/anonymous from user_roles; is the
  single source for feature gating (useIsAdmin stays the narrow admin check).
- useFeatureFlags consumes the real tier; catalog_analysis, ml_recommendations,
  ai_lab, reports move from admin → pro.
- AdminGate gains requirePro (admins included; no MFA step-up — Pro isn't
  backend). /catalog-analysis and /reports become Pro features; LeftNav nav
  items and the Index Teams section unlock for Pro; /admin/* stays admin-only.
- Admin → Roles: per-user Make/Revoke Pro (via admin_set_pro) with a Pro badge;
  Settings shows the account's plan (Admin/Pro/Member).

fmmusic821@gmail.com is pre-seeded into the Pro allowlist (keeps admin for now)
so that when an admin later revokes their admin role, Pro access is already in
place with no gap.

Verified: tsc, eslint, 362 tests, production build; migrations applied live
and reconciled (enum has 'pro', RPC admin-only/anon-blocked, fmmusic821 has
pro+admin).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CN6KKo8XyF2N2wBLxno24C
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
publisting Ready Ready Preview, Comment Jul 23, 2026 1:18pm

Request Review

@supabase

supabase Bot commented Jul 23, 2026

Copy link
Copy Markdown

Updates to Preview Branch (claude/publisting-audit-hardening-ixpwf6) ↗︎

Deployments Status Updated
Database Thu, 23 Jul 2026 13:17:57 UTC
Services Thu, 23 Jul 2026 13:17:57 UTC
APIs Thu, 23 Jul 2026 13:17:57 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Thu, 23 Jul 2026 13:18:06 UTC
Migrations Thu, 23 Jul 2026 13:18:36 UTC
Seeding Thu, 23 Jul 2026 13:18:38 UTC
Edge Functions Thu, 23 Jul 2026 13:19:05 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@demilt11-lab
demilt11-lab merged commit 0be59d3 into main Jul 23, 2026
7 checks passed
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.

2 participants