Fix installation loop, move install check and Auth check

This commit is contained in:
Sky Johnson 2024-07-17 12:58:13 -05:00
parent 167f28ff2c
commit 4f8edd5829
3 changed files with 9 additions and 13 deletions

View File

@ -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']);
}
}

View File

@ -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;
}
}
}

View File

@ -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']);
}
}
}