<?php namespace Illuminate\Auth; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\UserProvider; use Illuminate\Http\Request; use Illuminate\Support\Traits\Macroable; class RequestGuard implements Guard { use GuardHelpers, Macroable; /** * The guard callback. * * @var callable */ protected $callback; /** * The request instance. * * @var \Illuminate\Http\Request */ protected $request; /** * Create a new authentication guard. * * @param callable $callback * @param \Illuminate\Http\Request $request * @param \Illuminate\Contracts\Auth\UserProvider|null $provider * @return void */ public function __construct(callable $callback, Request $request, UserProvider $provider = null) { $this->request = $request; $this->callback = $callback; $this->provider = $provider; } /** * Get the currently authenticated user. * * @return \Illuminate\Contracts\Auth\Authenticatable|null */ public function user() { // If we've already retrieved the user for the current request we can just // return it back immediately. We do not want to fetch the user data on // every call to this method because that would be tremendously slow. if (! is_null($this->user)) { return $this->user; } return $this->user = call_user_func( $this->callback, $this->request, $this->getProvider() ); } /** * Validate a user's credentials. * * @param array $credentials * @return bool */ public function validate(array $credentials = []) { return ! is_null((new static( $this->callback, $credentials['request'], $this->getProvider() ))->user()); } /** * Set the current request instance. * * @param \Illuminate\Http\Request $request * @return $this */ public function setRequest(Request $request) { $this->request = $request; return $this; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Access | Folder | 0755 |
|
|
Console | Folder | 0755 |
|
|
Events | Folder | 0755 |
|
|
Listeners | Folder | 0755 |
|
|
Middleware | Folder | 0755 |
|
|
Notifications | Folder | 0755 |
|
|
Passwords | Folder | 0755 |
|
|
AuthManager.php | File | 8.25 KB | 0644 |
|
AuthServiceProvider.php | File | 3.04 KB | 0644 |
|
Authenticatable.php | File | 1.74 KB | 0644 |
|
AuthenticationException.php | File | 1.07 KB | 0644 |
|
CreatesUserProviders.php | File | 2.42 KB | 0644 |
|
DatabaseUserProvider.php | File | 4.6 KB | 0644 |
|
EloquentUserProvider.php | File | 6.18 KB | 0644 |
|
GenericUser.php | File | 2.49 KB | 0644 |
|
GuardHelpers.php | File | 2.54 KB | 0644 |
|
LICENSE.md | File | 1.05 KB | 0644 |
|
MustVerifyEmail.php | File | 979 B | 0644 |
|
Recaller.php | File | 1.83 KB | 0644 |
|
RequestGuard.php | File | 2.07 KB | 0644 |
|
SessionGuard.php | File | 26.48 KB | 0644 |
|
TokenGuard.php | File | 3.36 KB | 0644 |
|
composer.json | File | 1.24 KB | 0644 |
|