mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-04 10:05:53 +02:00
Updated gerbil key handeling
This commit is contained in:
parent
6cee5703b5
commit
7feb21e727
5 changed files with 25 additions and 17 deletions
|
@ -20,9 +20,10 @@ export async function ensureActions() {
|
|||
|
||||
// Add new actions
|
||||
for (const actionId of actionsToAdd) {
|
||||
logger.debug(`Adding action: ${actionId}`);
|
||||
await db.insert(actions).values({ actionId }).execute();
|
||||
// Add new actions to the Default role
|
||||
if (defaultRoles.length === 0) {
|
||||
if (defaultRoles.length != 0) {
|
||||
await db.insert(roleActions)
|
||||
.values(defaultRoles.map(role => ({ roleId: role.roleId!, actionId, orgId: role.orgId! })))
|
||||
.execute();
|
||||
|
@ -31,6 +32,7 @@ export async function ensureActions() {
|
|||
|
||||
// Remove deprecated actions
|
||||
if (actionsToRemove.length > 0) {
|
||||
logger.debug(`Removing actions: ${actionsToRemove.join(', ')}`);
|
||||
await db.delete(actions).where(inArray(actions.actionId, actionsToRemove)).execute();
|
||||
await db.delete(roleActions).where(inArray(roleActions.actionId, actionsToRemove)).execute();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,13 @@ import { eq, and } from "drizzle-orm";
|
|||
import { __DIRNAME } from "@server/config";
|
||||
|
||||
// Load the names from the names.json file
|
||||
const file = join(__DIRNAME, "names.json");
|
||||
const dev = process.env.ENVIRONMENT !== "prod";
|
||||
let file;
|
||||
if (!dev) {
|
||||
file = join(__DIRNAME, "names.json");
|
||||
} else {
|
||||
file = join(__DIRNAME, "/db/names.json");
|
||||
}
|
||||
export const names = JSON.parse(readFileSync(file, "utf-8"));
|
||||
|
||||
export async function getUniqueSiteName(orgId: string): Promise<string> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue