SessionGuard
class SessionGuard implements StatefulGuard, SupportsBasicAuth (View source)
Traits
Properties
protected Authenticatable | $user | The currently authenticated user. | from GuardHelpers |
protected UserProvider | $provider | The user provider implementation. | from GuardHelpers |
protected string | $name | The name of the Guard. Typically "session". | |
protected Authenticatable | $lastAttempted | The user we last attempted to retrieve. | |
protected bool | $viaRemember | Indicates if the user was authenticated via a recaller cookie. | |
protected SessionInterface | $session | The session used by the guard. | |
protected QueueingFactory | $cookie | The Illuminate cookie creator service. | |
protected Request | $request | The request instance. | |
protected Dispatcher | $events | The event dispatcher instance. | |
protected bool | $loggedOut | Indicates if the logout method has been called. | |
protected bool | $tokenRetrievalAttempted | Indicates if a token user retrieval has been attempted. |
Methods
Get the ID for the currently authenticated user.
Create a new authentication guard.
Get the currently authenticated user.
Pull a user from the repository by its recaller ID.
Get the decrypted recaller cookie for the request.
Get the user ID from the recaller cookie.
Determine if the recaller cookie is in a valid format.
Log a user into the application without sessions or cookies.
Validate a user's credentials.
Attempt to authenticate using HTTP Basic Auth.
Perform a stateless HTTP Basic login attempt.
Attempt to authenticate using basic authentication.
Get the credential array for a HTTP Basic request.
Get the response for basic authentication.
Attempt to authenticate a user using the given credentials.
Determine if the user matches the credentials.
Fire the attempt event with the arguments.
Fire the failed authentication attempt event with the given arguments.
Register an authentication attempt event listener.
Fire the login event if the dispatcher is set.
Update the session with the given ID.
Log the given user ID into the application.
Log the given user ID into the application without sessions or cookies.
Create a "remember me" cookie for a given ID.
Log the user out of the application.
Remove the user data from the session and cookies.
Create a new "remember me" token for the user if one doesn't already exist.
Get the cookie creator instance used by the guard.
Get the event dispatcher instance.
Get the session store used by the guard.
Get the user provider used by the guard.
Return the currently cached user.
Get the current request instance.
Set the current request instance.
Get the last user we attempted to authenticate.
Get a unique identifier for the auth session value.
Get the name of the cookie used to store the "recaller".
Determine if the user was authenticated via "remember me" cookie.
Details
in GuardHelpers at line 33
Authenticatable
authenticate()
Determine if the current user is authenticated.
in GuardHelpers at line 47
bool
check()
Determine if the current user is authenticated.
in GuardHelpers at line 57
bool
guest()
Determine if the current user is a guest.
at line 158
int|null
id()
Get the ID for the currently authenticated user.
at line 717
void
setUser(Authenticatable $user)
Set the current user.
at line 95
void
__construct(string $name, UserProvider $provider, SessionInterface $session, Request $request = null)
Create a new authentication guard.
at line 111
Authenticatable|null
user()
Get the currently authenticated user.
at line 179
protected mixed
getUserByRecaller(string $recaller)
Pull a user from the repository by its recaller ID.
at line 197
protected string|null
getRecaller()
Get the decrypted recaller cookie for the request.
at line 207
protected string|null
getRecallerId()
Get the user ID from the recaller cookie.
at line 220
protected bool
validRecaller(mixed $recaller)
Determine if the recaller cookie is in a valid format.
at line 237
bool
once(array $credentials = [])
Log a user into the application without sessions or cookies.
at line 254
bool
validate(array $credentials = [])
Validate a user's credentials.
at line 266
Response|null
basic(string $field = 'email', array $extraConditions = [])
Attempt to authenticate using HTTP Basic Auth.
at line 289
Response|null
onceBasic(string $field = 'email', array $extraConditions = [])
Perform a stateless HTTP Basic login attempt.
at line 306
protected bool
attemptBasic(Request $request, string $field, array $extraConditions = [])
Attempt to authenticate using basic authentication.
at line 324
protected array
getBasicCredentials(Request $request, string $field)
Get the credential array for a HTTP Basic request.
at line 334
protected Response
getBasicResponse()
Get the response for basic authentication.
at line 349
bool
attempt(array $credentials = [], bool $remember = false, bool $login = true)
Attempt to authenticate a user using the given credentials.
at line 383
protected bool
hasValidCredentials(mixed $user, array $credentials)
Determine if the user matches the credentials.
at line 396
protected void
fireAttemptEvent(array $credentials, bool $remember, bool $login)
Fire the attempt event with the arguments.
at line 412
protected void
fireFailedEvent(Authenticatable|null $user, array $credentials)
Fire the failed authentication attempt event with the given arguments.
at line 425
void
attempting(mixed $callback)
Register an authentication attempt event listener.
at line 439
void
login(Authenticatable $user, bool $remember = false)
Log a user into the application.
at line 467
protected void
fireLoginEvent(Authenticatable $user, bool $remember = false)
Fire the login event if the dispatcher is set.
at line 480
protected void
updateSession(string $id)
Update the session with the given ID.
at line 494
Authenticatable
loginUsingId(mixed $id, bool $remember = false)
Log the given user ID into the application.
at line 513
bool
onceUsingId(mixed $id)
Log the given user ID into the application without sessions or cookies.
at line 532
protected void
queueRecallerCookie(Authenticatable $user)
Queue the recaller cookie into the cookie jar.
at line 545
protected Cookie
createRecaller(string $value)
Create a "remember me" cookie for a given ID.
at line 555
void
logout()
Log the user out of the application.
at line 585
protected void
clearUserDataFromStorage()
Remove the user data from the session and cookies.
at line 602
protected void
refreshRememberToken(Authenticatable $user)
Refresh the "remember me" token for the user.
at line 615
protected void
createRememberTokenIfDoesntExist(Authenticatable $user)
Create a new "remember me" token for the user if one doesn't already exist.
at line 629
QueueingFactory
getCookieJar()
Get the cookie creator instance used by the guard.
at line 644
void
setCookieJar(QueueingFactory $cookie)
Set the cookie creator instance used by the guard.
at line 654
Dispatcher
getDispatcher()
Get the event dispatcher instance.
at line 665
void
setDispatcher(Dispatcher $events)
Set the event dispatcher instance.
at line 685
UserProvider
getProvider()
Get the user provider used by the guard.
at line 696
void
setProvider(UserProvider $provider)
Set the user provider used by the guard.
at line 706
Authenticatable|null
getUser()
Return the currently cached user.
at line 731
Request
getRequest()
Get the current request instance.
at line 742
$this
setRequest(Request $request)
Set the current request instance.
at line 754
Authenticatable
getLastAttempted()
Get the last user we attempted to authenticate.
at line 764
string
getName()
Get a unique identifier for the auth session value.
at line 774
string
getRecallerName()
Get the name of the cookie used to store the "recaller".
at line 784
bool
viaRemember()
Determine if the user was authenticated via "remember me" cookie.