Seed: bridge LobeChat default signup accounts to enterprise roles
E2E CI / Check Duplicate Run (push) Failing after 2s
Test CI / Check Duplicate Run (push) Failing after 2s
E2E CI / Test Web App (push) Has been skipped
🔄 Branch Synchronization / sync-branches (push) Failing after 3s
Test CI / Test Packages (push) Has been skipped
Test CI / Test App (shard 1/3) (push) Has been skipped
Test CI / Test App (shard 3/3) (push) Has been skipped
Test CI / Test App (shard 2/3) (push) Has been skipped
Test CI / Test Desktop App (push) Has been skipped
Test CI / Test Database (push) Has been skipped
Test CI / Merge and Upload App Coverage (push) Has been skipped
E2E CI / Check Duplicate Run (push) Failing after 2s
Test CI / Check Duplicate Run (push) Failing after 2s
E2E CI / Test Web App (push) Has been skipped
🔄 Branch Synchronization / sync-branches (push) Failing after 3s
Test CI / Test Packages (push) Has been skipped
Test CI / Test App (shard 1/3) (push) Has been skipped
Test CI / Test App (shard 3/3) (push) Has been skipped
Test CI / Test App (shard 2/3) (push) Has been skipped
Test CI / Test Desktop App (push) Has been skipped
Test CI / Test Database (push) Has been skipped
Test CI / Merge and Upload App Coverage (push) Has been skipped
- admin@eg.local -> super_admin - user1@eg.local -> customer (customer_id=CUST-0001) Makes the admin-only model-config UI lock take effect out of the box after docker compose up + bootstrap-lobechat-users.sh.
This commit is contained in:
@@ -69,8 +69,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "gateway/prisma/seed.ts",
|
"path": "gateway/prisma/seed.ts",
|
||||||
"accessCount": 20,
|
"accessCount": 23,
|
||||||
"lastAccessed": 1776763220682,
|
"lastAccessed": 1776775293304,
|
||||||
"type": "file"
|
"type": "file"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"lastSentAt": "2026-04-21T12:33:30.508Z"
|
"lastSentAt": "2026-04-21T12:40:13.486Z"
|
||||||
}
|
}
|
||||||
@@ -332,6 +332,32 @@ async function ensureModels() {
|
|||||||
console.log('[seed] models/model-permissions/model-policy ensured');
|
console.log('[seed] models/model-permissions/model-policy ensured');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bridge the default LobeChat signup accounts to enterprise roles so the UI
|
||||||
|
// admin-lock takes effect immediately out of the box. This is idempotent.
|
||||||
|
async function ensureLobeChatBridgeUsers() {
|
||||||
|
const bridges = [
|
||||||
|
{ email: 'admin@eg.local', username: 'admin-lobe', displayName: 'Admin (LobeChat)', role: 'super_admin', metadata: {} as any },
|
||||||
|
{ email: 'user1@eg.local', username: 'user1-lobe', displayName: 'User One (LobeChat)', role: 'customer', metadata: { customer_id: 'CUST-0001' } as any },
|
||||||
|
];
|
||||||
|
for (const b of bridges) {
|
||||||
|
const role = await prisma.enterpriseRole.findUnique({ where: { key: b.role } });
|
||||||
|
if (!role) continue;
|
||||||
|
let user = await prisma.enterpriseUser.findUnique({ where: { username: b.username } });
|
||||||
|
if (!user) {
|
||||||
|
user = await prisma.enterpriseUser.create({
|
||||||
|
data: { username: b.username, displayName: b.displayName, email: b.email, metadata: b.metadata },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const existing = await prisma.enterpriseUserRole.findFirst({
|
||||||
|
where: { userId: user.id, roleId: role.id },
|
||||||
|
});
|
||||||
|
if (!existing) {
|
||||||
|
await prisma.enterpriseUserRole.create({ data: { userId: user.id, roleId: role.id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('[seed] lobechat bridge users ensured');
|
||||||
|
}
|
||||||
|
|
||||||
async function ensureSystemDiscoverer() {
|
async function ensureSystemDiscoverer() {
|
||||||
const superRole = await prisma.enterpriseRole.findUnique({ where: { key: 'super_admin' } });
|
const superRole = await prisma.enterpriseRole.findUnique({ where: { key: 'super_admin' } });
|
||||||
if (!superRole) return;
|
if (!superRole) return;
|
||||||
@@ -385,6 +411,7 @@ async function main() {
|
|||||||
await ensureToolInputSchemas();
|
await ensureToolInputSchemas();
|
||||||
await ensureModels();
|
await ensureModels();
|
||||||
await ensureRoleToolGrants();
|
await ensureRoleToolGrants();
|
||||||
|
await ensureLobeChatBridgeUsers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user