From 558bef7817dd0cdc04b536ec844ff5f2d6a1e2c6 Mon Sep 17 00:00:00 2001 From: objecttothis Date: Wed, 8 Feb 2023 00:20:04 +0400 Subject: [PATCH] Sessions issues. Not fixed yet. --- app/Controllers/Home.php | 3 ++- app/Controllers/Login.php | 1 + app/Controllers/Secure_Controller.php | 18 +++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 0dbe0a279..121e4a059 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -6,11 +6,12 @@ class Home extends Secure_Controller { public function __construct() { - parent::__construct(NULL, NULL, 'home'); + parent::__construct('home', NULL, 'home'); } public function getIndex(): void { + $logged_in = $this->employee->is_logged_in(); echo view('home/home'); } diff --git a/app/Controllers/Login.php b/app/Controllers/Login.php index 452ca5a75..f5c3e40d7 100644 --- a/app/Controllers/Login.php +++ b/app/Controllers/Login.php @@ -57,6 +57,7 @@ class Login extends BaseController $migration->setNamespace('App')->latest(); } } + return redirect()->to('home'); } } diff --git a/app/Controllers/Secure_Controller.php b/app/Controllers/Secure_Controller.php index a53a55725..9a3a1835d 100644 --- a/app/Controllers/Secure_Controller.php +++ b/app/Controllers/Secure_Controller.php @@ -13,13 +13,15 @@ use CodeIgniter\Session\Session; * * @property employee employee * @property module module - * + * @property array global_view_data * @property session session * */ class Secure_Controller extends BaseController { - public function __construct(string $module_id = NULL, string $submodule_id = NULL, string $menu_group = NULL) + public array $global_view_data; + + public function __construct(string $module_id = '', string $submodule_id = NULL, string $menu_group = NULL) { $this->employee = model('Employee'); $this->module = model('Module'); @@ -36,7 +38,7 @@ class Secure_Controller extends BaseController redirect("no_access/$module_id/$submodule_id"); } - // load up global data visible to all the loaded views + // load up global global_view_data visible to all the loaded views $this->session = session(); if($menu_group == NULL) { @@ -58,13 +60,11 @@ class Secure_Controller extends BaseController foreach($allowed_modules->getResult() as $module) { - $data['allowed_modules'][] = $module; + $global_view_data['allowed_modules'][] = $module; } - $data['user_info'] = $logged_in_employee_info; - $data['controller_name'] = $module_id; - - echo view('viewData', $data); + $global_view_data['user_info'] = $logged_in_employee_info; + $global_view_data['controller_name'] = $module_id; } public function check_numeric() @@ -86,4 +86,4 @@ class Secure_Controller extends BaseController public function view(int $data_item_id = -1) { return FALSE; } public function save(int $data_item_id = -1) { return FALSE; } public function delete() { return FALSE; } -} \ No newline at end of file +}