Fix installation loop, move install check and Auth check
This commit is contained in:
parent
167f28ff2c
commit
4f8edd5829
|
@ -18,6 +18,7 @@ class App
|
||||||
self::$req = new Request(); // the current request
|
self::$req = new Request(); // the current request
|
||||||
self::$db = new Database($dbPath); // the database
|
self::$db = new Database($dbPath); // the database
|
||||||
self::$dbPath = $dbPath; // the database path
|
self::$dbPath = $dbPath; // the database path
|
||||||
|
self::$auth = new Auth();
|
||||||
|
|
||||||
// stuff that can only be loaded if the database is installed
|
// stuff that can only be loaded if the database is installed
|
||||||
if (INSTALLED) {
|
if (INSTALLED) {
|
||||||
|
@ -25,8 +26,8 @@ class App
|
||||||
$s = self::$db->q('SELECT * FROM settings WHERE id = 1;');
|
$s = self::$db->q('SELECT * FROM settings WHERE id = 1;');
|
||||||
self::$s = $s ? $s->fetch() : [];
|
self::$s = $s ? $s->fetch() : [];
|
||||||
|
|
||||||
// init authentication
|
// load the player's auth
|
||||||
self::$auth = new Auth();
|
self::$auth->good();
|
||||||
}
|
}
|
||||||
|
|
||||||
// load flash messages
|
// load flash messages
|
||||||
|
@ -59,6 +60,6 @@ class App
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
// clean up flash messages
|
// clean up flash messages
|
||||||
$_SESSION['flash'] = [];
|
unset($_SESSION['flash']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,6 @@ class Auth
|
||||||
// id of the player
|
// id of the player
|
||||||
public static int $id = 0;
|
public static int $id = 0;
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->good();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function login(string $identifier, string $password, bool $remember = false): bool
|
public function login(string $identifier, string $password, bool $remember = false): bool
|
||||||
{
|
{
|
||||||
// delete the old session
|
// delete the old session
|
||||||
|
|
|
@ -254,6 +254,9 @@ class InstallModule
|
||||||
'expires' DATETIME NOT NULL
|
'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]);
|
echo render('install/layout', ['title' => 'Database Setup', 'step' => 'second', 'complete' => $complete, 'start' => $istart]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,9 +297,6 @@ class InstallModule
|
||||||
'level' => $_POST['level'] ?? 1
|
'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
|
// login the admin
|
||||||
App::$auth->login($_POST['username'], $_POST['password']);
|
App::$auth->login($_POST['username'], $_POST['password']);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user