Skip to content

Commit

Permalink
Tweaks for custom main module
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisnikoy committed Apr 26, 2024
1 parent 0da2f34 commit 2e1e266
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function getUser(): mixed {

return null;
}

/**
* Retrieves the current user credentials if a valid session is found.
*
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2e1e266

Please sign in to comment.