Просмотр исходного кода

Fix out of order superuser role

Owen Schwartz 9 месяцев назад
Родитель
Сommit
d54cf34377
2 измененных файлов с 7 добавлено и 9 удалено
  1. 1 0
      server/config.ts
  2. 6 9
      server/db/ensureActions.ts

+ 1 - 0
server/config.ts

@@ -11,6 +11,7 @@ const environmentSchema = z.object({
         name: z.string(),
         environment: z.enum(["dev", "prod"]),
         base_url: z.string().url(),
+        base_domain: z.string(),
         log_level: z.enum(["debug", "info", "warn", "error"]),
         save_logs: z.string().transform((val) => val === "true"),
     }),

+ 6 - 9
server/db/ensureActions.ts

@@ -18,18 +18,15 @@ export async function ensureActions() {
         .where(eq(roles.isSuperuserRole, true))
         .execute();
 
-    if (defaultRoles.length === 0) {
-        logger.info('No default roles to assign');
-        return;
-    }
-
     // Add new actions
     for (const actionId of actionsToAdd) {
-    await db.insert(actions).values({ actionId }).execute();
+        await db.insert(actions).values({ actionId }).execute();
         // Add new actions to the Default role
-        await db.insert(roleActions)
-            .values(defaultRoles.map(role => ({ roleId: role.roleId!, actionId, orgId: role.orgId! })))
-            .execute();
+        if (defaultRoles.length === 0) {
+            await db.insert(roleActions)
+                .values(defaultRoles.map(role => ({ roleId: role.roleId!, actionId, orgId: role.orgId! })))
+                .execute();
+        }
     }
 
     // Remove deprecated actions