mirror of
https://github.com/detleph/server.git
synced 2026-09-07 07:56:18 +02:00
Only create default admin when in development mode
This commit is contained in:
+19
-14
@@ -19,21 +19,26 @@ require("dotenv").config(); // Load dotenv config
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "development") {
|
|
||||||
logger.info("Using development mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
// Dev
|
if (process.env.NODE_ENV === "development") {
|
||||||
await prisma.admin.upsert({
|
logger.info("Using development mode");
|
||||||
where: { id: 1 },
|
logger.warning(
|
||||||
create: {
|
"This mode should not be used in any production-near environment as it is significantly less secure than the production mode"
|
||||||
name: "admin",
|
);
|
||||||
password: await argon2.hash("test", { type: argon2.argon2id }),
|
|
||||||
permission_level: "ELEVATED",
|
// TODO: How should you login to the prod server by default? Maybe random password?
|
||||||
},
|
await prisma.admin.upsert({
|
||||||
update: {},
|
where: { id: 1 },
|
||||||
});
|
create: {
|
||||||
|
name: "admin",
|
||||||
|
password: await argon2.hash("test", { type: argon2.argon2id }),
|
||||||
|
permission_level: "ELEVATED",
|
||||||
|
},
|
||||||
|
update: {},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.info("Using production mode");
|
||||||
|
}
|
||||||
|
|
||||||
// Todo: Everything
|
// Todo: Everything
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user