Conversie codeigniter 4
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user