RequestGuard
class RequestGuard implements Guard
Traits
These methods are typically the same across all guards.
Properties
| protected UserProvider|null | $provider | The user provider implementation. |
from GuardHelpers |
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected callable | $callback | The guard callback. |
Methods
Determine if the current user is authenticated. If not, throw an exception.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new authentication guard.
Get the currently authenticated user.
Validate a user's credentials.
Determine if the guard has a user instance.
Forget the current user.
Get durable authentication Context keys for the current request.
Get the Context key for caching the authenticated user.
Flush all static state.
Details
in
GuardHelpers at line 32
Authenticatable
authenticate()
Determine if the current user is authenticated. If not, throw an exception.
in
GuardHelpers at line 40
bool
check()
Determine if the current user is authenticated.
in
GuardHelpers at line 48
bool
guest()
Determine if the current user is a guest.
in
GuardHelpers at line 56
int|string|null
id()
Get the ID for the currently authenticated user.
in
GuardHelpers at line 64
UserProvider|null
getProvider()
Get the user provider used by the guard.
in
GuardHelpers 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.
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 40
__construct(string $name, callable $callback, Container $app, UserProvider|null $provider = null)
Create a new authentication guard.
The $name parameter is a Hypervel addition for coroutine-safe Context keying. Each named guard needs a unique Context key so multiple RequestGuard instances don't collide.
at line 58
Authenticatable|null
user()
Get the currently authenticated user.
Uses coroutine Context to cache the resolved user per-request, since this guard is a process-global singleton. A sentinel value is used to cache "no user found" so repeated calls don't trigger redundant provider lookups.
at line 86
bool
validate(array $credentials = [])
Validate a user's credentials.
at line 97
bool
hasUser()
Determine if the guard has a user instance.
at line 109
Guard
setUser(Authenticatable $user)
Set the current user.
at line 119
RequestGuard
forgetUser()
Forget the current user.
at line 131
array
getAuthContextKeys()
Get durable authentication Context keys for the current request.
at line 139
protected string
getContextKey()
Get the Context key for caching the authenticated user.
at line 147
static void
flushState()
Flush all static state.