trait GuardHelpers

These methods are typically the same across all guards.

In Hypervel, guards are process-global singletons (cached in AuthManager::$guards), so per-request user state cannot be stored as instance properties. Each guard must implement its own coroutine-safe user(), setUser(), and hasUser() using Context. This trait provides only the methods that are truly universal across all guards.

Properties

protected UserProvider|null $provider

The user provider implementation.

Methods

authenticate()

Determine if the current user is authenticated. If not, throw an exception.

bool
check()

Determine if the current user is authenticated.

bool
guest()

Determine if the current user is a guest.

int|string|null
id()

Get the ID for the currently authenticated user.

getProvider()

Get the user provider used by the guard.

void
setProvider(UserProvider $provider)

Set the user provider used by the guard.

Details

at line 32
Authenticatable authenticate()

Determine if the current user is authenticated. If not, throw an exception.

Return Value

Authenticatable

Exceptions

AuthenticationException

at line 40
bool check()

Determine if the current user is authenticated.

Return Value

bool

at line 48
bool guest()

Determine if the current user is a guest.

Return Value

bool

at line 56
int|string|null id()

Get the ID for the currently authenticated user.

Return Value

int|string|null

at line 64
UserProvider|null getProvider()

Get the user provider used by the guard.

Return Value

UserProvider|null

at line 75
void setProvider(UserProvider $provider)

Set the user provider used by the guard.

Boot or tests only. The provider is stored on the worker-lifetime guard and affects every subsequent request.

Parameters

UserProvider $provider

Return Value

void