Skip to content

Gate


  • Full name: \Codefy\Framework\Auth\Gate

Properties

rbac

protected \Codefy\Framework\Auth\Rbac\Rbac $rbac

user

protected \Codefy\Framework\Auth\Repository\AuthUserRepository $user

Methods

__construct

public __construct(\Codefy\Framework\Auth\Rbac\Rbac $rbac, \Codefy\Framework\Auth\Repository\AuthUserRepository $user): mixed

Parameters:

Parameter Type Description
$rbac \Codefy\Framework\Auth\Rbac\Rbac
$user \Codefy\Framework\Auth\Repository\AuthUserRepository

can

Authorization check.

public can(string $permissionName, array $ruleParams = []): bool

Parameters:

Parameter Type Description
$permissionName string
$ruleParams array

Throws:


current

Get the current authenticated user model.

public current(): object|bool|null

Throws:


hasAuthenticatedUser

Whether user is authenticated.

private hasAuthenticatedUser(): bool

resolveUserByToken

private resolveUserByToken(string $token): object|bool|null

Parameters:

Parameter Type Description
$token string

Throws:


getRoles

private getRoles(): array

Throws:


guest

A guest is any user without an authenticated token.

public guest(): bool

isLoggedIn

Whether user is logged in.

public isLoggedIn(): bool

getToken

Fetch decrypted token from request context.

private getToken(): ?string

getRequest

Return request object.

private getRequest(): \Psr\Http\Message\ServerRequestInterface|null