Auth
final class Auth
Static entry point to the application's auth guard. Lazily constructs a single SessionGuard so every caller shares one resolved user per request, and forwards the common guard operations (check, user, id) to it. A guard may also be injected via setGuard() to support testing.
Properties
| static private Guard|null | $guard | The shared guard instance for the current request, or null until first constructed. |
Methods
Determines whether a user is currently authenticated.
Gets the identifier of the currently authenticated user.
Sets the shared guard instance, replacing any existing one. Intended primarily for testing, where a guard backed by a fake provider or session can be injected. Passing null resets the guard so the next call to guard() constructs a fresh default instance.
Gets the currently authenticated user.
Details
at line 29
static bool
check()
Determines whether a user is currently authenticated.
at line 36
static Guard
guard()
Returns the shared guard, constructing it on first use.
at line 51
static mixed
id()
Gets the identifier of the currently authenticated user.
at line 65
static void
setGuard(Guard|null $guard)
Sets the shared guard instance, replacing any existing one. Intended primarily for testing, where a guard backed by a fake provider or session can be injected. Passing null resets the guard so the next call to guard() constructs a fresh default instance.
at line 75
static Principal|null
user()
Gets the currently authenticated user.