From 3d99854c9db5249ff84f6952919a87448d71b08f Mon Sep 17 00:00:00 2001 From: cyclane Date: Sun, 4 Jul 2021 17:26:04 +0100 Subject: [PATCH] Added guest --- src/lib/permissions.ts | 5 ++++- src/server.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/permissions.ts b/src/lib/permissions.ts index 0b567d0..c7a49c6 100644 --- a/src/lib/permissions.ts +++ b/src/lib/permissions.ts @@ -1,5 +1,8 @@ export enum Permissions { - ALL = "*" + ALL = "*", + VIEW_PROFILE = "view_profile", + ADD_PROFILE = "add_profile", + MANAGE_PERMISSIONS = "manage_permissions" } /** diff --git a/src/server.ts b/src/server.ts index df5dc44..c68e49a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -6,6 +6,7 @@ import * as sapper from "@sapper/server"; import arangojs, { Database, aql } from "arangojs"; import { hash } from "bcrypt"; import { log } from "./logger"; +import { Permissions } from "./lib/permissions"; const { PORT, NODE_ENV, DB_USERNAME, DB_PASSWORD, DB_URL, DB_NAME, API_KEY } = process.env; @@ -33,7 +34,11 @@ const intervalFunc = async (db: Database) => { username: DB_USERNAME, password: await hash(DB_PASSWORD || "SBDataTracker", saltRounds), forceChangePassword: true, - permissions: ["*"] + permissions: [Permissions.ALL] + }); + await users.save({ + username: "_guest", + permissions: [Permissions.VIEW_PROFILE] }); } @@ -74,6 +79,9 @@ const intervalFunc = async (db: Database) => { ); } }; + // Separated into setInterval and a setTimeout so when the script is started, + // immediately at least one profile is logged. This is useful for debugging + // since you don't have to wait for up to 3 minutes to pass. if ((cursor.count as number) > 1) interval = setInterval( iterate,