feat: roles/permissions system and Nostr profile display on admin users
Introduce granular role-based permissions with SuperAdmin env override, admin roles UI, and permission-gated API routes. Fix admin user Nostr metadata by batching relay profile fetches, normalizing npub pubkeys to hex, and adding reusable NostrAvatar/useNostrProfile components. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { DEFAULT_ROLE_PERMISSIONS } from '../src/constants/permissions';
|
||||
|
||||
dotenv.config({ path: path.resolve(__dirname, '../../.env') });
|
||||
|
||||
@@ -87,6 +88,18 @@ async function main() {
|
||||
});
|
||||
}
|
||||
|
||||
// Seed default role permissions. This only fills in missing rows so it never
|
||||
// clobbers permissions an operator has customized at runtime.
|
||||
for (const [role, permissions] of Object.entries(DEFAULT_ROLE_PERMISSIONS)) {
|
||||
for (const permission of permissions) {
|
||||
await prisma.rolePermission.upsert({
|
||||
where: { role_permission: { role, permission } },
|
||||
update: {},
|
||||
create: { role, permission },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Seed completed successfully.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user