GuardHelpers
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 null|TProvider | $provider | The user provider implementation. |
Methods
Determine if the current user is authenticated. If not, throw an exception.
Determine if the current user is authenticated.
Determine if the current user is a guest.
Get the ID for the currently authenticated user.
Get the user provider used by the guard.
Get this guard's coroutine context key for the given entry.
Details
at line 55
Authenticatable
authenticate()
Determine if the current user is authenticated. If not, throw an exception.
at line 63
bool
check()
Determine if the current user is authenticated.
at line 71
bool
guest()
Determine if the current user is a guest.
at line 79
int|string|null
id()
Get the ID for the currently authenticated user.
at line 89
UserProvider|null
getProvider()
Get the user provider used by the guard.
at line 102
void
setProvider(UserProvider $provider)
Set the user provider used by the guard.
The provider is stored on the worker-lifetime guard and affects every subsequent request.
at line 111
protected string
contextKey(string $key)
Get this guard's coroutine context key for the given entry.