W3cubDocs

/Laravel 5.4

Guard

class Guard implements Guard (View source)

Methods

void __construct(UserProvider $provider, SessionInterface $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.

Authenticatable|null user()

Get the currently authenticated user.

int|null id()

Get the ID for the currently authenticated user.

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')

Attempt to authenticate using HTTP Basic Auth.

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

Perform a stateless HTTP Basic login attempt.

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

Attempt to authenticate a user using the given credentials.

void attempting(mixed $callback)

Register an authentication attempt event listener.

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

Log a user into the application.

Authenticatable 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 logout()

Log the user out of the application.

QueueingFactory getCookieJar()

Get the cookie creator instance used by the guard.

void setCookieJar(QueueingFactory $cookie)

Set the cookie creator instance used by the guard.

Dispatcher getDispatcher()

Get the event dispatcher instance.

void setDispatcher(Dispatcher $events)

Set the event dispatcher instance.

Store getSession()

Get the session store used by the guard.

UserProvider getProvider()

Get the user provider used by the guard.

void setProvider(UserProvider $provider)

Set the user provider used by the guard.

Authenticatable|null getUser()

Return the currently cached user.

void setUser(Authenticatable $user)

Set the current user.

Request getRequest()

Get the current request instance.

$this setRequest(Request $request)

Set the current request instance.

Authenticatable 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(UserProvider $provider, SessionInterface $session, Request $request = null)

Create a new authentication guard.

Parameters

UserProvider $provider
SessionInterface $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

Authenticatable|null user()

Get the currently authenticated user.

Return Value

Authenticatable|null

int|null id()

Get the ID for the currently authenticated user.

Return Value

int|null

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')

Attempt to authenticate using HTTP Basic Auth.

Parameters

string $field

Return Value

Response|null

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

Perform a stateless HTTP Basic login attempt.

Parameters

string $field

Return Value

Response|null

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

void attempting(mixed $callback)

Register an authentication attempt event listener.

Parameters

mixed $callback

Return Value

void

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

Log a user into the application.

Parameters

Authenticatable $user
bool $remember

Return Value

void

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

Log the given user ID into the application.

Parameters

mixed $id
bool $remember

Return Value

Authenticatable

bool onceUsingId(mixed $id)

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

Parameters

mixed $id

Return Value

bool

void logout()

Log the user out of the application.

Return Value

void

QueueingFactory getCookieJar()

Get the cookie creator instance used by the guard.

Return Value

QueueingFactory

Exceptions

RuntimeException

void setCookieJar(QueueingFactory $cookie)

Set the cookie creator instance used by the guard.

Parameters

QueueingFactory $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

UserProvider getProvider()

Get the user provider used by the guard.

Return Value

UserProvider

void setProvider(UserProvider $provider)

Set the user provider used by the guard.

Parameters

UserProvider $provider

Return Value

void

Authenticatable|null getUser()

Return the currently cached user.

Return Value

Authenticatable|null

void setUser(Authenticatable $user)

Set the current user.

Parameters

Authenticatable $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

Authenticatable getLastAttempted()

Get the last user we attempted to authenticate.

Return Value

Authenticatable

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

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.4/Illuminate/Auth/Guard.html