Added guest
This commit is contained in:
parent
af2c334e66
commit
3d99854c9d
|
@ -1,5 +1,8 @@
|
||||||
export enum Permissions {
|
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 arangojs, { Database, aql } from "arangojs";
|
||||||
import { hash } from "bcrypt";
|
import { hash } from "bcrypt";
|
||||||
import { log } from "./logger";
|
import { log } from "./logger";
|
||||||
|
import { Permissions } from "./lib/permissions";
|
||||||
|
|
||||||
const { PORT, NODE_ENV, DB_USERNAME, DB_PASSWORD, DB_URL, DB_NAME, API_KEY } =
|
const { PORT, NODE_ENV, DB_USERNAME, DB_PASSWORD, DB_URL, DB_NAME, API_KEY } =
|
||||||
process.env;
|
process.env;
|
||||||
|
@ -33,7 +34,11 @@ const intervalFunc = async (db: Database) => {
|
||||||
username: DB_USERNAME,
|
username: DB_USERNAME,
|
||||||
password: await hash(DB_PASSWORD || "SBDataTracker", saltRounds),
|
password: await hash(DB_PASSWORD || "SBDataTracker", saltRounds),
|
||||||
forceChangePassword: true,
|
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)
|
if ((cursor.count as number) > 1)
|
||||||
interval = setInterval(
|
interval = setInterval(
|
||||||
iterate,
|
iterate,
|
||||||
|
|
Loading…
Reference in New Issue