接入云端账号库给别人开访问必须做这步

接好后:任何人可在任意设备注册与登录,您在任意设备都能审核,密码由云端校验而不留在浏览器里。

当前模式的真实局限(请先看懂)

没接云端账号库时,登录注册走浏览器本地模式:账号与审核记录存在各自设备的浏览器里,不在您的服务器上。

所以:本地模式只能验证「密码校验 + 审核流程」这套逻辑是否工作,不能真正给外人开访问。
要把链接发给老师、同事或任何其他人并审核他们,必须接入云端账号库(下方步骤,约 15 分钟)。接入后申请记录存在云端,您在哪台设备登录审核后台都能看到全部申请。

接入步骤(约 15 分钟,只需做一次)

  1. 打开 https://supabase.com 免费注册(GitHub 账号可一键登录),新建一个项目(免费额度够用,选地区时选离您近的)。
  2. 项目左侧点 SQL Editor → New query。
  3. 把下方代码框里全部内容粘贴进去,点 Run。看到 Success 即完成。
  4. 项目 → Settings → API,复制两个值:Project URL 和 anon public key。
  5. 把这两个值填进本项目的 auth-config.js,重新部署即可。

下载 SQL 文件一键复制 SQL

要执行的 SQL(完整内容)

建 profiles 表存申请与审核结果,并开启行级安全策略——关键在于它带 status 字段,默认为 pending,只有管理员能改成 approved。

-- RMC 收益管理社区 · 访问审核数据表
-- 在 Supabase → SQL Editor → New query 中粘贴全部内容,点 Run

-- 1) 建表
create table if not exists public.profiles (
  id          uuid primary key references auth.users(id) on delete cascade,
  email       text unique not null,
  full_name   text,
  org         text,
  phone       text,
  reason      text,
  status      text not null default 'pending'
              check (status in ('pending','approved','rejected')),
  note        text,
  reviewed_at timestamptz,
  created_at  timestamptz not null default now()
);

-- 2) 索引
create index if not exists profiles_status_idx on public.profiles (status);

-- 3) 开启行级安全(必须开,否则匿名密钥可读写全表)
alter table public.profiles enable row level security;

-- 4) 策略
drop policy if exists "allow insert pending" on public.profiles;
create policy "allow insert pending" on public.profiles
  for insert to anon, authenticated
  with check (status = 'pending');

drop policy if exists "read own" on public.profiles;
create policy "read own" on public.profiles
  for select to authenticated
  using (auth.uid() = id);

drop policy if exists "admin read all" on public.profiles;
create policy "admin read all" on public.profiles
  for select to authenticated
  using ((auth.jwt() ->> 'email') = '3984557428@qq.com');

drop policy if exists "admin update" on public.profiles;
create policy "admin update" on public.profiles
  for update to authenticated
  using ((auth.jwt() ->> 'email') = '3984557428@qq.com')
  with check ((auth.jwt() ->> 'email') = '3984557428@qq.com');

-- 5) 新用户注册自动建 pending 记录;管理员邮箱自动 approved
create or replace function public.handle_new_user()
returns trigger
language plpgsql
security definer set search_path = public
as $$
begin
  insert into public.profiles (id, email, full_name, status, created_at)
  values (
    new.id,
    new.email,
    coalesce(new.raw_user_meta_data->>'full_name',''),
    case when new.email = '3984557428@qq.com' then 'approved' else 'pending' end,
    now()
  )
  on conflict (email) do update set status = excluded.status;
  return new;
end;
$$;

drop trigger if exists on_auth_user_created on auth.users;
create trigger on_auth_user_created
  after insert on auth.users
  for each row execute function public.handle_new_user();

接好之后,怎么用

打开审核后台打开登录页

安全提醒