class Guard (View source)

Properties

protected UserInterface $user The currently authenticated user.
protected UserInterface $lastAttempted The user we last attempted to retrieve.
protected bool $viaRemember Indicates if the user was authenticated via a recaller cookie.
protected UserProviderInterface $provider The user provider implementation.
protected Store $session The session store used by the guard.
$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

void
__construct(UserProviderInterface $provider, Store $session, Request $request = null)

Create a new authentication guard.

bool
check()

Determine if the current user is authenticated.

bool
guest()

Determine if the current user is a guest.

user()

Get the currently authenticated user.

int|null
id()

Get the ID for the currently authenticated user.

mixed
getUserByRecaller(string $recaller)

Pull a user from the repository by its recaller ID.

string|null
getRecaller()

Get the decrypted recaller cookie for the request.

string
getRecallerId()

Get the user ID from the recaller cookie.

bool
validRecaller(string $recaller)

Determine if the recaller cookie is in a valid format.

bool
once(array $credentials = array())

Log a user into the application without sessions or cookies.

bool
validate(array $credentials = array())

Validate a user's credentials.

Response|null
basic(string $field = 'email', Request $request = null)

Attempt to authenticate using HTTP Basic Auth.

Response|null
onceBasic(string $field = 'email', Request $request = null)

Perform a stateless HTTP Basic login attempt.

bool
attemptBasic(Request $request, string $field)

Attempt to authenticate using basic authentication.

array
getBasicCredentials(Request $request, string $field)

Get the credential array for a HTTP Basic request.

Response
getBasicResponse()

Get the response for basic authentication.

bool
attempt(array $credentials = array(), bool $remember = false, bool $login = true)

Attempt to authenticate a user using the given credentials.

bool
hasValidCredentials(mixed $user, array $credentials)

Determine if the user matches the credentials.

void
fireAttemptEvent(array $credentials, bool $remember, bool $login)

Fire the attempt event with the arguments.

void
attempting(mixed $callback)

Register an authentication attempt event listener.

void
login(UserInterface $user, bool $remember = false)

Log a user into the application.

void
updateSession(string $id)

Update the session with the given ID.

loginUsingId(mixed $id, bool $remember = false)

Log the given user ID into the application.

bool
onceUsingId(mixed $id)

Log the given user ID into the application without sessions or cookies.

void
queueRecallerCookie(UserInterface $user)

Queue the recaller cookie into the cookie jar.

Cookie
createRecaller(string $value)

Create a remember me cookie for a given ID.

void
logout()

Log the user out of the application.

void
clearUserDataFromStorage()

Remove the user data from the session and cookies.

void
refreshRememberToken(UserInterface $user)

Refresh the remember token for the user.

void
createRememberTokenIfDoesntExist(UserInterface $user)

Create a new remember token for the user if one doesn't already exist.

getCookieJar()

Get the cookie creator instance used by the guard.

void
setCookieJar(CookieJar $cookie)

Set the cookie creator instance used by the guard.

getDispatcher()

Get the event dispatcher instance.

void
setDispatcher(Dispatcher $events)

Set the event dispatcher instance.

getSession()

Get the session store used by the guard.

getProvider()

Get the user provider used by the guard.

void
setProvider(UserProviderInterface $provider)

Set the user provider used by the guard.

getUser()

Return the currently cached user of the application.

void
setUser(UserInterface $user)

Set the current user of the application.

Request
getRequest()

Get the current request instance.

$this
setRequest(Request $request)

Set the current request instance.

getLastAttempted()

Get the last user we attempted to authenticate.

string
getName()

Get a unique identifier for the auth session value.

string
getRecallerName()

Get the name of the cookie used to store the "recaller".

bool
viaRemember()

Determine if the user was authenticated via "remember me" cookie.

Details

void __construct(UserProviderInterface $provider, Store $session, Request $request = null)

Create a new authentication guard.

Parameters

UserProviderInterface $provider
Store $session
Request $request

Return Value

void

bool check()

Determine if the current user is authenticated.

Return Value

bool

bool guest()

Determine if the current user is a guest.

Return Value

bool

UserInterface|null user()

Get the currently authenticated user.

Return Value

UserInterface|null

int|null id()

Get the ID for the currently authenticated user.

Return Value

int|null

protected mixed getUserByRecaller(string $recaller)

Pull a user from the repository by its recaller ID.

Parameters

string $recaller

Return Value

mixed

protected string|null getRecaller()

Get the decrypted recaller cookie for the request.

Return Value

string|null

protected string getRecallerId()

Get the user ID from the recaller cookie.

Return Value

string

protected bool validRecaller(string $recaller)

Determine if the recaller cookie is in a valid format.

Parameters

string $recaller

Return Value

bool

bool once(array $credentials = array())

Log a user into the application without sessions or cookies.

Parameters

array $credentials

Return Value

bool

bool validate(array $credentials = array())

Validate a user's credentials.

Parameters

array $credentials

Return Value

bool

Response|null basic(string $field = 'email', Request $request = null)

Attempt to authenticate using HTTP Basic Auth.

Parameters

string $field
Request $request

Return Value

Response|null

Response|null onceBasic(string $field = 'email', Request $request = null)

Perform a stateless HTTP Basic login attempt.

Parameters

string $field
Request $request

Return Value

Response|null

protected bool attemptBasic(Request $request, string $field)

Attempt to authenticate using basic authentication.

Parameters

Request $request
string $field

Return Value

bool

protected array getBasicCredentials(Request $request, string $field)

Get the credential array for a HTTP Basic request.

Parameters

Request $request
string $field

Return Value

array

protected Response getBasicResponse()

Get the response for basic authentication.

Return Value

Response

bool attempt(array $credentials = array(), bool $remember = false, bool $login = true)

Attempt to authenticate a user using the given credentials.

Parameters

array $credentials
bool $remember
bool $login

Return Value

bool

protected bool hasValidCredentials(mixed $user, array $credentials)

Determine if the user matches the credentials.

Parameters

mixed $user
array $credentials

Return Value

bool

protected void fireAttemptEvent(array $credentials, bool $remember, bool $login)

Fire the attempt event with the arguments.

Parameters

array $credentials
bool $remember
bool $login

Return Value

void

void attempting(mixed $callback)

Register an authentication attempt event listener.

Parameters

mixed $callback

Return Value

void

void login(UserInterface $user, bool $remember = false)

Log a user into the application.

Parameters

UserInterface $user
bool $remember

Return Value

void

protected void updateSession(string $id)

Update the session with the given ID.

Parameters

string $id

Return Value

void

UserInterface loginUsingId(mixed $id, bool $remember = false)

Log the given user ID into the application.

Parameters

mixed $id
bool $remember

Return Value

UserInterface

bool onceUsingId(mixed $id)

Log the given user ID into the application without sessions or cookies.

Parameters

mixed $id

Return Value

bool

protected void queueRecallerCookie(UserInterface $user)

Queue the recaller cookie into the cookie jar.

Parameters

UserInterface $user

Return Value

void

protected Cookie createRecaller(string $value)

Create a remember me cookie for a given ID.

Parameters

string $value

Return Value

Cookie

void logout()

Log the user out of the application.

Return Value

void

protected void clearUserDataFromStorage()

Remove the user data from the session and cookies.

Return Value

void

protected void refreshRememberToken(UserInterface $user)

Refresh the remember token for the user.

Parameters

UserInterface $user

Return Value

void

protected void createRememberTokenIfDoesntExist(UserInterface $user)

Create a new remember token for the user if one doesn't already exist.

Parameters

UserInterface $user

Return Value

void

CookieJar getCookieJar()

Get the cookie creator instance used by the guard.

Return Value

CookieJar

Exceptions

RuntimeException

void setCookieJar(CookieJar $cookie)

Set the cookie creator instance used by the guard.

Parameters

CookieJar $cookie

Return Value

void

Dispatcher getDispatcher()

Get the event dispatcher instance.

Return Value

Dispatcher

void setDispatcher(Dispatcher $events)

Set the event dispatcher instance.

Parameters

Dispatcher $events

Return Value

void

Store getSession()

Get the session store used by the guard.

Return Value

Store

UserProviderInterface getProvider()

Get the user provider used by the guard.

Return Value

UserProviderInterface

void setProvider(UserProviderInterface $provider)

Set the user provider used by the guard.

Parameters

UserProviderInterface $provider

Return Value

void

UserInterface|null getUser()

Return the currently cached user of the application.

Return Value

UserInterface|null

void setUser(UserInterface $user)

Set the current user of the application.

Parameters

UserInterface $user

Return Value

void

Request getRequest()

Get the current request instance.

Return Value

Request

$this setRequest(Request $request)

Set the current request instance.

Parameters

Request $request

Return Value

$this

UserInterface getLastAttempted()

Get the last user we attempted to authenticate.

Return Value

UserInterface

string getName()

Get a unique identifier for the auth session value.

Return Value

string

string getRecallerName()

Get the name of the cookie used to store the "recaller".

Return Value

string

bool viaRemember()

Determine if the user was authenticated via "remember me" cookie.

Return Value

bool