From 2e1e2667b254cd36a968b509c3101623e71528aa Mon Sep 17 00:00:00 2001 From: Jannis Nikou Date: Fri, 26 Apr 2024 08:34:35 -0700 Subject: [PATCH] Tweaks for custom main module --- src/Auth.php | 8 ++++++-- src/Module.php | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index c7058fe..9411acb 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -132,7 +132,7 @@ public function getUser(): mixed { return null; } - + /** * Retrieves the current user credentials if a valid session is found. * @@ -206,7 +206,11 @@ private function attemptLogin(string $username, string $password): bool { $sessionId = md5($row->username . $row->password . time()); - $this->db->query('INSERT INTO exm_sessions(id, user_id, expires_at) VALUES(?, ?, to_timestamp(?))', $sessionId, $row->id, time()+$this->ttl); + if($this->config->get('db_provider') == 'pgsql') { + $this->db->query('INSERT INTO exm_sessions(id, user_id, expires_at) VALUES(?, ?, to_timestamp(?))', $sessionId, $row->id, time()+$this->ttl); + } else { + $this->db->query('INSERT INTO exm_sessions(id, user_id, expires_at) VALUES(?, ?, FROM_UNIXTIME(?))', $sessionId, $row->id, time()+$this->ttl); + } $this->storeSessionData($sessionId); $this->loggedIn = true; diff --git a/src/Module.php b/src/Module.php index ae185d9..e9e6cb9 100644 --- a/src/Module.php +++ b/src/Module.php @@ -150,6 +150,14 @@ private function loadController(string $moduleName, string $moduleAction = null, * Attempts to find the default controller and loads it if found. */ private function loadDefaultController(): void { + foreach ($this->config->get('module_dirs') as $directory) { + + if(file_exists($directory . '/AthosController.php')) { + require_once $directory . '/AthosController.php'; + $this->loadController('Athos', null, false); + } + } + if(file_exists(SITE_PATH . '/modules/DefaultController.php')) { require_once SITE_PATH.'/modules/DefaultController.php'; $this->loadController('Default', null, false);