dbmsv4 init...5
This commit is contained in:
parent
e8e43405f5
commit
47cafc947b
@ -40,30 +40,28 @@ class AuthContext
|
|||||||
|
|
||||||
public function getUID(): int
|
public function getUID(): int
|
||||||
{
|
{
|
||||||
$uid = $this->getAuthInfo('uid');
|
return $this->getAuthInfo('uid');
|
||||||
|
|
||||||
if ($uid === null || $uid === '') {
|
|
||||||
throw new \RuntimeException('Not logged in');
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) $uid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID(): string|null
|
public function getID(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('id');
|
return $this->getAuthInfo('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string|null
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('name');
|
return $this->getAuthInfo('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRole(): array|null
|
public function getRole(): string
|
||||||
{
|
{
|
||||||
return $this->getAuthInfo('role');
|
return $this->getAuthInfo('role');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRoles(): array
|
||||||
|
{
|
||||||
|
return explode(DEFAULTS['DELIMITER_COMMA'], $this->getRole());
|
||||||
|
}
|
||||||
public function isLoggedIn(): bool
|
public function isLoggedIn(): bool
|
||||||
{
|
{
|
||||||
return $this->session->has(self::SESSION_IS_LOGIN);
|
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_IS_LOGIN, true);
|
||||||
$this->session->set(self::SESSION_AUTH_INFO, [
|
$this->session->set(self::SESSION_AUTH_INFO, [
|
||||||
'uid' => $entity->getPK(),
|
'uid' => (int) $entity->getPK(),
|
||||||
'id' => $entity->getID(),
|
'id' => $entity->getID(),
|
||||||
'name' => $entity->getTitle(),
|
'name' => $entity->getTitle(),
|
||||||
'role' => $entity->getRole()
|
'role' => $entity->getRole()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user