mirror of
https://github.com/bitbaum/evig.git
synced 2026-12-04 10:57:29 +01:00
Database Changes: - Migration 004: Add is_super_admin column to users table - Sync existing super admins from SUPER_ADMIN_EMAILS list Auth Updates: - auth.ts: Add is_super_admin to User and Session types - auth.ts: Pass is_super_admin through JWT to session - db.ts: Add is_super_admin to DbUser interface - permissions.ts: Update isSuperAdmin() to check both email list and DB flag - permissions.ts: Add is_super_admin to StaffUser interface API Endpoints: - PATCH /api/admin/users/[id]/permissions - Super admins can update staff permissions directly - Super admins can promote/demote other super admins - Cannot demote users in hardcoded SUPER_ADMIN_EMAILS list - Cannot demote yourself UI Components: - UserPermissionsEditor: Modal for managing user permissions - Toggle super admin status - Toggle full access - Select individual section permissions - Visual distinction for sensitive sections Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
39 lines
1.6 KiB
SQL
39 lines
1.6 KiB
SQL
-- ============================================================================
|
|
-- RevampIT Super Admin Management Migration
|
|
-- Created: 2026-01-20
|
|
-- Description: Adds is_super_admin column for database-managed super admins
|
|
-- ============================================================================
|
|
|
|
-- ============================================================================
|
|
-- 1. ADD IS_SUPER_ADMIN COLUMN TO USERS TABLE
|
|
-- ============================================================================
|
|
|
|
ALTER TABLE users ADD COLUMN IF NOT EXISTS is_super_admin BOOLEAN DEFAULT FALSE;
|
|
|
|
-- ============================================================================
|
|
-- 2. SYNC EXISTING SUPER ADMINS FROM PERMISSIONS.TS
|
|
-- Set is_super_admin = true for emails that are in the hardcoded list
|
|
-- ============================================================================
|
|
|
|
UPDATE users
|
|
SET is_super_admin = TRUE
|
|
WHERE email IN (
|
|
'andreas@revamp-it.ch',
|
|
'veronica@revamp-it.ch',
|
|
'daniel@revamp-it.ch',
|
|
'georgy@revamp-it.ch',
|
|
'georgy.butaev@revamp-it.ch'
|
|
);
|
|
|
|
-- ============================================================================
|
|
-- 3. CREATE INDEX
|
|
-- ============================================================================
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_users_is_super_admin ON users(is_super_admin);
|
|
|
|
-- ============================================================================
|
|
-- 4. COMMENTS
|
|
-- ============================================================================
|
|
|
|
COMMENT ON COLUMN users.is_super_admin IS 'True if user is a super admin. Can be managed by other super admins.';
|