feat: add platform admin permissions

This commit is contained in:
Codex
2026-06-30 07:50:02 +08:00
parent 51f8cbdec8
commit 780feee4f8
20 changed files with 392 additions and 63 deletions

View File

@@ -832,11 +832,11 @@ async function normalizeUsers(records: JsonRecord[]) {
`
insert into public.platform_users (
legacy_id, username, email, phone, name, avatar_url, primary_role, score,
last_seen_at, password_migration_required, raw_profile, created_at, updated_at
last_seen_at, password_migration_required, platform_permissions, raw_profile, created_at, updated_at
)
values ($1,$2,$3,$4,$5,$6,$7,$8,nullif($9::text,'')::timestamptz,true,$10,
coalesce(nullif($11::text,'')::timestamptz, now()),
coalesce(nullif($12::text,'')::timestamptz, now())
values ($1,$2,$3,$4,$5,$6,$7,$8,nullif($9::text,'')::timestamptz,true,$10::jsonb,$11,
coalesce(nullif($12::text,'')::timestamptz, now()),
coalesce(nullif($13::text,'')::timestamptz, now())
)
on conflict (legacy_id) do update set
username = excluded.username,
@@ -846,6 +846,7 @@ async function normalizeUsers(records: JsonRecord[]) {
avatar_url = excluded.avatar_url,
primary_role = excluded.primary_role,
score = excluded.score,
platform_permissions = excluded.platform_permissions,
raw_profile = excluded.raw_profile,
updated_at = excluded.updated_at
`,
@@ -856,9 +857,10 @@ async function normalizeUsers(records: JsonRecord[]) {
text(r.phone),
text(r.name) || text(r.username),
text(r.avatar),
text(r.role) || 'student',
normalizeTenantRole(r.role),
intValue(r.score),
dateText(r.lastSeenAt),
normalizeTenantRole(r.role) === 'platform_admin' ? JSON.stringify({ '*': true }) : JSON.stringify({}),
JSON.stringify(safeProfile),
dateText(r.created),
dateText(r.updated),