From a59c08fa6a7c75dacf77e4bafefe3c4af8ce4908 Mon Sep 17 00:00:00 2001 From: Owen Schwartz Date: Mon, 21 Oct 2024 22:13:53 -0400 Subject: [PATCH] Fix out of order superuser role --- server/config.ts | 1 + server/db/ensureActions.ts | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/server/config.ts b/server/config.ts index dc7aaa00..0543d162 100644 --- a/server/config.ts +++ b/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"), }), diff --git a/server/db/ensureActions.ts b/server/db/ensureActions.ts index 95951daa..8db1e066 100644 --- a/server/db/ensureActions.ts +++ b/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