From 4f8edd58293590674a29906e76a0a4ee0602fef6 Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Wed, 17 Jul 2024 12:58:13 -0500 Subject: [PATCH] Fix installation loop, move install check and Auth check --- server/app/App.php | 7 ++++--- server/app/Auth.php | 7 +------ server/modules/InstallModule.php | 8 ++++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/server/app/App.php b/server/app/App.php index 1106b6a..88e90d0 100644 --- a/server/app/App.php +++ b/server/app/App.php @@ -18,6 +18,7 @@ class App self::$req = new Request(); // the current request self::$db = new Database($dbPath); // the database self::$dbPath = $dbPath; // the database path + self::$auth = new Auth(); // stuff that can only be loaded if the database is installed if (INSTALLED) { @@ -25,8 +26,8 @@ class App $s = self::$db->q('SELECT * FROM settings WHERE id = 1;'); self::$s = $s ? $s->fetch() : []; - // init authentication - self::$auth = new Auth(); + // load the player's auth + self::$auth->good(); } // load flash messages @@ -59,6 +60,6 @@ class App public function __destruct() { // clean up flash messages - $_SESSION['flash'] = []; + unset($_SESSION['flash']); } } diff --git a/server/app/Auth.php b/server/app/Auth.php index 2b9fb31..233d246 100644 --- a/server/app/Auth.php +++ b/server/app/Auth.php @@ -13,11 +13,6 @@ class Auth // id of the player public static int $id = 0; - public function __construct() - { - $this->good(); - } - public function login(string $identifier, string $password, bool $remember = false): bool { // delete the old session @@ -77,4 +72,4 @@ class Auth return false; } -} \ No newline at end of file +} diff --git a/server/modules/InstallModule.php b/server/modules/InstallModule.php index cefc06e..ad9eea9 100644 --- a/server/modules/InstallModule.php +++ b/server/modules/InstallModule.php @@ -254,6 +254,9 @@ class InstallModule 'expires' DATETIME NOT NULL );"); + // Create the .installed file in the server folder + file_put_contents(SERVER.'/.installed', 'Installed on '.date('Y-m-d H:i:s')); + echo render('install/layout', ['title' => 'Database Setup', 'step' => 'second', 'complete' => $complete, 'start' => $istart]); } @@ -294,9 +297,6 @@ class InstallModule 'level' => $_POST['level'] ?? 1 ]); - // Create the .installed file in the server folder - file_put_contents(SERVER.'/.installed', 'Installed on '.date('Y-m-d H:i:s')); - // login the admin App::$auth->login($_POST['username'], $_POST['password']); @@ -309,4 +309,4 @@ class InstallModule { echo render('install/layout', ['title' => 'Four Oh Four', 'step' => 'four']); } -} \ No newline at end of file +}