From d2d6bbc5143e2c9b85ce97a35d72465b0b81fdb1 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:49:08 -0700 Subject: [PATCH] Fix bug where accounts.js tries to create admin account before database is initialized --- database/accounts/accounts.js | 2 +- database/database.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/database/accounts/accounts.js b/database/accounts/accounts.js index 84c7a35..d33d11f 100644 --- a/database/accounts/accounts.js +++ b/database/accounts/accounts.js @@ -27,7 +27,7 @@ async function checkForAdminAccount() { console.log("Created temp admin account 'admin@example.com' with password 'admin'."); } } -checkForAdminAccount(); +database.initializationStatus.then(() => checkForAdminAccount()); passport.use(new localStrategy({ diff --git a/database/database.js b/database/database.js index 349e2bc..7390426 100644 --- a/database/database.js +++ b/database/database.js @@ -36,10 +36,11 @@ async function checkForDatabaseInitialization() { await Initialize(); } } -checkForDatabaseInitialization(); +const initializationStatus = checkForDatabaseInitialization(); -exports.executeQuery = executeQuery; \ No newline at end of file +exports.executeQuery = executeQuery; +exports.initializationStatus = initializationStatus; \ No newline at end of file