SessionGuard
in package
implements
StatefulGuard, SupportsBasicAuth
Uses
GuardHelpers, Macroable
Interfaces, Classes and Traits
Table of Contents
- $cookie : QueueingFactory
- The Illuminate cookie creator service.
- $events : Dispatcher
- The event dispatcher instance.
- $lastAttempted : Authenticatable
- The user we last attempted to retrieve.
- $loggedOut : bool
- Indicates if the logout method has been called.
- $macros : array<string|int, mixed>
- The registered string macros.
- $name : string
- The name of the Guard. Typically "session".
- $provider : UserProvider
- The user provider implementation.
- $recallAttempted : bool
- Indicates if a token user retrieval has been attempted.
- $request : Request
- The request instance.
- $session : Session
- The session used by the guard.
- $user : Authenticatable
- The currently authenticated user.
- $viaRemember : bool
- Indicates if the user was authenticated via a recaller cookie.
- __call() : mixed
- Dynamically handle calls to the class.
- __callStatic() : mixed
- Dynamically handle calls to the class.
- __construct() : void
- Create a new authentication guard.
- attempt() : bool
- Attempt to authenticate a user using the given credentials.
- attempting() : void
- Register an authentication attempt event listener.
- authenticate() : Authenticatable
- Determine if the current user is authenticated.
- basic() : void
- Attempt to authenticate using HTTP Basic Auth.
- check() : bool
- Determine if the current user is authenticated.
- getCookieJar() : QueueingFactory
- Get the cookie creator instance used by the guard.
- getDispatcher() : Dispatcher
- Get the event dispatcher instance.
- getLastAttempted() : Authenticatable
- Get the last user we attempted to authenticate.
- getName() : string
- Get a unique identifier for the auth session value.
- getProvider() : UserProvider
- Get the user provider used by the guard.
- getRecallerName() : string
- Get the name of the cookie used to store the "recaller".
- getRequest() : Request
- Get the current request instance.
- getSession() : Session
- Get the session store used by the guard.
- getUser() : Authenticatable|null
- Return the currently cached user.
- guest() : bool
- Determine if the current user is a guest.
- hasMacro() : bool
- Checks if macro is registered.
- id() : int|null
- Get the ID for the currently authenticated user.
- login() : void
- Log a user into the application.
- loginUsingId() : Authenticatable|false
- Log the given user ID into the application.
- logout() : void
- Log the user out of the application.
- macro() : void
- Register a custom macro.
- mixin() : void
- Mix another object into the class.
- once() : bool
- Log a user into the application without sessions or cookies.
- onceBasic() : void
- Perform a stateless HTTP Basic login attempt.
- onceUsingId() : Authenticatable|false
- Log the given user ID into the application without sessions or cookies.
- setCookieJar() : void
- Set the cookie creator instance used by the guard.
- setDispatcher() : void
- Set the event dispatcher instance.
- setProvider() : void
- Set the user provider used by the guard.
- setRequest() : $this
- Set the current request instance.
- setUser() : $this
- Set the current user.
- user() : Authenticatable|null
- Get the currently authenticated user.
- validate() : bool
- Validate a user's credentials.
- viaRemember() : bool
- Determine if the user was authenticated via "remember me" cookie.
- attemptBasic() : bool
- Attempt to authenticate using basic authentication.
- basicCredentials() : array<string|int, mixed>
- Get the credential array for a HTTP Basic request.
- clearUserDataFromStorage() : void
- Remove the user data from the session and cookies.
- createRecaller() : Cookie
- Create a "remember me" cookie for a given ID.
- cycleRememberToken() : void
- Refresh the "remember me" token for the user.
- ensureRememberTokenIsSet() : void
- Create a new "remember me" token for the user if one doesn't already exist.
- failedBasicResponse() : void
- Get the response for basic authentication.
- fireAttemptEvent() : void
- Fire the attempt event with the arguments.
- fireAuthenticatedEvent() : void
- Fire the authenticated event if the dispatcher is set.
- fireFailedEvent() : void
- Fire the failed authentication attempt event with the given arguments.
- fireLoginEvent() : void
- Fire the login event if the dispatcher is set.
- hasValidCredentials() : bool
- Determine if the user matches the credentials.
- queueRecallerCookie() : void
- Queue the recaller cookie into the cookie jar.
- recaller() : Recaller|null
- Get the decrypted recaller cookie for the request.
- updateSession() : void
- Update the session with the given ID.
- userFromRecaller() : mixed
- Pull a user from the repository by its "remember me" cookie token.
Properties
$cookie
The Illuminate cookie creator service.
protected
QueueingFactory
$cookie
$events
The event dispatcher instance.
protected
Dispatcher
$events
$lastAttempted
The user we last attempted to retrieve.
protected
Authenticatable
$lastAttempted
$loggedOut
Indicates if the logout method has been called.
protected
bool
$loggedOut
= false
$macros
The registered string macros.
protected
static array<string|int, mixed>
$macros
= []
$name
The name of the Guard. Typically "session".
protected
string
$name
Corresponds to guard name in authentication configuration.
$provider
The user provider implementation.
protected
UserProvider
$provider
$recallAttempted
Indicates if a token user retrieval has been attempted.
protected
bool
$recallAttempted
= false
$request
The request instance.
protected
Request
$request
$session
The session used by the guard.
protected
Session
$session
$user
The currently authenticated user.
protected
Authenticatable
$user
$viaRemember
Indicates if the user was authenticated via a recaller cookie.
protected
bool
$viaRemember
= false
Methods
__call()
Dynamically handle calls to the class.
public
__call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
Return values
mixed —__callStatic()
Dynamically handle calls to the class.
public
static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
Return values
mixed —__construct()
Create a new authentication guard.
public
__construct(string $name, UserProvider $provider, Session $session[, Request $request = null ]) : void
Parameters
- $name : string
- $provider : UserProvider
- $session : Session
- $request : Request = null
Return values
void —attempt()
Attempt to authenticate a user using the given credentials.
public
attempt([array<string|int, mixed> $credentials = [] ][, bool $remember = false ]) : bool
Parameters
- $credentials : array<string|int, mixed> = []
- $remember : bool = false
Return values
bool —attempting()
Register an authentication attempt event listener.
public
attempting(mixed $callback) : void
Parameters
- $callback : mixed
Return values
void —authenticate()
Determine if the current user is authenticated.
public
authenticate() : Authenticatable
Tags
Return values
Authenticatable —basic()
Attempt to authenticate using HTTP Basic Auth.
public
basic([string $field = 'email' ][, array<string|int, mixed> $extraConditions = [] ]) : void
Parameters
- $field : string = 'email'
- $extraConditions : array<string|int, mixed> = []
Tags
Return values
void —check()
Determine if the current user is authenticated.
public
check() : bool
Return values
bool —getCookieJar()
Get the cookie creator instance used by the guard.
public
getCookieJar() : QueueingFactory
Tags
Return values
QueueingFactory —getDispatcher()
Get the event dispatcher instance.
public
getDispatcher() : Dispatcher
Return values
Dispatcher —getLastAttempted()
Get the last user we attempted to authenticate.
public
getLastAttempted() : Authenticatable
Return values
Authenticatable —getName()
Get a unique identifier for the auth session value.
public
getName() : string
Return values
string —getProvider()
Get the user provider used by the guard.
public
getProvider() : UserProvider
Return values
UserProvider —getRecallerName()
Get the name of the cookie used to store the "recaller".
public
getRecallerName() : string
Return values
string —getRequest()
Get the current request instance.
public
getRequest() : Request
Return values
Request —getSession()
Get the session store used by the guard.
public
getSession() : Session
Return values
Session —getUser()
Return the currently cached user.
public
getUser() : Authenticatable|null
Return values
Authenticatable|null —guest()
Determine if the current user is a guest.
public
guest() : bool
Return values
bool —hasMacro()
Checks if macro is registered.
public
static hasMacro(string $name) : bool
Parameters
- $name : string
Return values
bool —id()
Get the ID for the currently authenticated user.
public
id() : int|null
Return values
int|null —login()
Log a user into the application.
public
login(Authenticatable $user[, bool $remember = false ]) : void
Parameters
- $user : Authenticatable
- $remember : bool = false
Return values
void —loginUsingId()
Log the given user ID into the application.
public
loginUsingId(mixed $id[, bool $remember = false ]) : Authenticatable|false
Parameters
- $id : mixed
- $remember : bool = false
Return values
Authenticatable|false —logout()
Log the user out of the application.
public
logout() : void
Return values
void —macro()
Register a custom macro.
public
static macro(string $name, object|callable $macro) : void
Parameters
- $name : string
- $macro : object|callable
Return values
void —mixin()
Mix another object into the class.
public
static mixin(object $mixin) : void
Parameters
- $mixin : object
Return values
void —once()
Log a user into the application without sessions or cookies.
public
once([array<string|int, mixed> $credentials = [] ]) : bool
Parameters
- $credentials : array<string|int, mixed> = []
Return values
bool —onceBasic()
Perform a stateless HTTP Basic login attempt.
public
onceBasic([string $field = 'email' ][, array<string|int, mixed> $extraConditions = [] ]) : void
Parameters
- $field : string = 'email'
- $extraConditions : array<string|int, mixed> = []
Tags
Return values
void —onceUsingId()
Log the given user ID into the application without sessions or cookies.
public
onceUsingId(mixed $id) : Authenticatable|false
Parameters
- $id : mixed
Return values
Authenticatable|false —setCookieJar()
Set the cookie creator instance used by the guard.
public
setCookieJar(QueueingFactory $cookie) : void
Parameters
- $cookie : QueueingFactory
Return values
void —setDispatcher()
Set the event dispatcher instance.
public
setDispatcher(Dispatcher $events) : void
Parameters
- $events : Dispatcher
Return values
void —setProvider()
Set the user provider used by the guard.
public
setProvider(UserProvider $provider) : void
Parameters
- $provider : UserProvider
Return values
void —setRequest()
Set the current request instance.
public
setRequest(Request $request) : $this
Parameters
- $request : Request
Return values
$this —setUser()
Set the current user.
public
setUser(Authenticatable $user) : $this
Parameters
- $user : Authenticatable
Return values
$this —user()
Get the currently authenticated user.
public
user() : Authenticatable|null
Return values
Authenticatable|null —validate()
Validate a user's credentials.
public
validate([array<string|int, mixed> $credentials = [] ]) : bool
Parameters
- $credentials : array<string|int, mixed> = []
Return values
bool —viaRemember()
Determine if the user was authenticated via "remember me" cookie.
public
viaRemember() : bool
Return values
bool —attemptBasic()
Attempt to authenticate using basic authentication.
protected
attemptBasic(Request $request, string $field[, array<string|int, mixed> $extraConditions = [] ]) : bool
Parameters
- $request : Request
- $field : string
- $extraConditions : array<string|int, mixed> = []
Return values
bool —basicCredentials()
Get the credential array for a HTTP Basic request.
protected
basicCredentials(Request $request, string $field) : array<string|int, mixed>
Parameters
- $request : Request
- $field : string
Return values
array<string|int, mixed> —clearUserDataFromStorage()
Remove the user data from the session and cookies.
protected
clearUserDataFromStorage() : void
Return values
void —createRecaller()
Create a "remember me" cookie for a given ID.
protected
createRecaller(string $value) : Cookie
Parameters
- $value : string
Return values
Cookie —cycleRememberToken()
Refresh the "remember me" token for the user.
protected
cycleRememberToken(Authenticatable $user) : void
Parameters
- $user : Authenticatable
Return values
void —ensureRememberTokenIsSet()
Create a new "remember me" token for the user if one doesn't already exist.
protected
ensureRememberTokenIsSet(Authenticatable $user) : void
Parameters
- $user : Authenticatable
Return values
void —failedBasicResponse()
Get the response for basic authentication.
protected
failedBasicResponse() : void
Tags
Return values
void —fireAttemptEvent()
Fire the attempt event with the arguments.
protected
fireAttemptEvent(array<string|int, mixed> $credentials[, bool $remember = false ]) : void
Parameters
- $credentials : array<string|int, mixed>
- $remember : bool = false
Return values
void —fireAuthenticatedEvent()
Fire the authenticated event if the dispatcher is set.
protected
fireAuthenticatedEvent(Authenticatable $user) : void
Parameters
- $user : Authenticatable
Return values
void —fireFailedEvent()
Fire the failed authentication attempt event with the given arguments.
protected
fireFailedEvent(Authenticatable|null $user, array<string|int, mixed> $credentials) : void
Parameters
- $user : Authenticatable|null
- $credentials : array<string|int, mixed>
Return values
void —fireLoginEvent()
Fire the login event if the dispatcher is set.
protected
fireLoginEvent(Authenticatable $user[, bool $remember = false ]) : void
Parameters
- $user : Authenticatable
- $remember : bool = false
Return values
void —hasValidCredentials()
Determine if the user matches the credentials.
protected
hasValidCredentials(mixed $user, array<string|int, mixed> $credentials) : bool
Parameters
- $user : mixed
- $credentials : array<string|int, mixed>
Return values
bool —queueRecallerCookie()
Queue the recaller cookie into the cookie jar.
protected
queueRecallerCookie(Authenticatable $user) : void
Parameters
- $user : Authenticatable
Return values
void —recaller()
Get the decrypted recaller cookie for the request.
protected
recaller() : Recaller|null
Return values
Recaller|null —updateSession()
Update the session with the given ID.
protected
updateSession(string $id) : void
Parameters
- $id : string
Return values
void —userFromRecaller()
Pull a user from the repository by its "remember me" cookie token.
protected
userFromRecaller(Recaller $recaller) : mixed
Parameters
- $recaller : Recaller