validate()) { View::forwardTo('/users/login'); } else { $this->loadUserRole(); } } /** * @desc checks if the user is logged in, if yes it loads the corresponding user role into the session. * @return void * [auth] => Array ( [session_id] => SESSION_ID [user_id] => USER_ID [login] => USER_LOGIN [role] => ACL_ROLE ) */ public function loadUserRole(): void { if(User::validate()) { $userRole = User::getRoleByLoggedInUser(); $_SESSION['auth']['role'] = $userRole['acl_role']; } } /** * @desc will load the acl roles from the database and return them as an array. * @return array * @throws \Exception */ public function loadAclRoles(): array { $acl = Db::loadModel('WarehouseLoach\Acl'); return $acl->loadTableAsArray(); } }