46 lines
903 B
PHP
46 lines
903 B
PHP
<?php
|
|
|
|
namespace App\Libraries\Beheer\Session;
|
|
|
|
use CodeIgniter\Session\Session;
|
|
|
|
class RetrieveUserSession
|
|
{
|
|
private Session $session;
|
|
|
|
public function __construct(Session $session)
|
|
{
|
|
$this->session = $session;
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
$this->setUserID();
|
|
$this->setRole();
|
|
$this->setAuthenticated();
|
|
}
|
|
|
|
private function setUserID(): void
|
|
{
|
|
$userId = $this->session->get('userID');
|
|
if (!defined('USERID')) {
|
|
define('USERID', $userId);
|
|
}
|
|
}
|
|
|
|
private function setRole(): void
|
|
{
|
|
$role = $this->session->get('role');
|
|
if (!defined('ROLE')) {
|
|
define('ROLE', $role);
|
|
}
|
|
}
|
|
|
|
private function setAuthenticated(): void
|
|
{
|
|
if (!defined('AUTHENTICATED')) {
|
|
define('AUTHENTICATED', USERID ? true : false);
|
|
}
|
|
}
|
|
}
|