mirror of
				https://gitlab.com/cyclane/sbdatatracker.git
				synced 2025-11-04 08:57:07 +00:00 
			
		
		
		
	Added guest
This commit is contained in:
		@@ -1,5 +1,8 @@
 | 
			
		||||
export enum Permissions {
 | 
			
		||||
	ALL = "*"
 | 
			
		||||
	ALL = "*",
 | 
			
		||||
	VIEW_PROFILE = "view_profile",
 | 
			
		||||
	ADD_PROFILE = "add_profile",
 | 
			
		||||
	MANAGE_PERMISSIONS = "manage_permissions"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user