diff --git a/app/Libraries/AuthContext.php b/app/Libraries/AuthContext.php index ffeb91b..3b44a2c 100644 --- a/app/Libraries/AuthContext.php +++ b/app/Libraries/AuthContext.php @@ -40,30 +40,28 @@ class AuthContext public function getUID(): int { - $uid = $this->getAuthInfo('uid'); - - if ($uid === null || $uid === '') { - throw new \RuntimeException('Not logged in'); - } - - return (int) $uid; + return $this->getAuthInfo('uid'); } - public function getID(): string|null + public function getID(): string { return $this->getAuthInfo('id'); } - public function getName(): string|null + public function getName(): string { return $this->getAuthInfo('name'); } - public function getRole(): array|null + public function getRole(): string { return $this->getAuthInfo('role'); } + public function getRoles(): array + { + return explode(DEFAULTS['DELIMITER_COMMA'], $this->getRole()); + } public function isLoggedIn(): bool { return $this->session->has(self::SESSION_IS_LOGIN); @@ -104,7 +102,7 @@ class AuthContext { $this->session->set(self::SESSION_IS_LOGIN, true); $this->session->set(self::SESSION_AUTH_INFO, [ - 'uid' => $entity->getPK(), + 'uid' => (int) $entity->getPK(), 'id' => $entity->getID(), 'name' => $entity->getTitle(), 'role' => $entity->getRole()