Pressroom template verwijderd, website naar root van repo
This commit is contained in:
10
vendor/laravel/framework/src/Illuminate/Auth/Access/AuthorizationException.php
vendored
Normal file
10
vendor/laravel/framework/src/Illuminate/Auth/Access/AuthorizationException.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AuthorizationException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
506
vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php
vendored
Normal file
506
vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php
vendored
Normal file
@@ -0,0 +1,506 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
|
||||
class Gate implements GateContract
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* The container instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Container\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* The user resolver callable.
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
protected $userResolver;
|
||||
|
||||
/**
|
||||
* All of the defined abilities.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $abilities = [];
|
||||
|
||||
/**
|
||||
* All of the defined policies.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [];
|
||||
|
||||
/**
|
||||
* All of the registered before callbacks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $beforeCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the registered after callbacks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $afterCallbacks = [];
|
||||
|
||||
/**
|
||||
* Create a new gate instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Container\Container $container
|
||||
* @param callable $userResolver
|
||||
* @param array $abilities
|
||||
* @param array $policies
|
||||
* @param array $beforeCallbacks
|
||||
* @param array $afterCallbacks
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Container $container, callable $userResolver, array $abilities = [],
|
||||
array $policies = [], array $beforeCallbacks = [], array $afterCallbacks = [])
|
||||
{
|
||||
$this->policies = $policies;
|
||||
$this->container = $container;
|
||||
$this->abilities = $abilities;
|
||||
$this->userResolver = $userResolver;
|
||||
$this->afterCallbacks = $afterCallbacks;
|
||||
$this->beforeCallbacks = $beforeCallbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given ability has been defined.
|
||||
*
|
||||
* @param string $ability
|
||||
* @return bool
|
||||
*/
|
||||
public function has($ability)
|
||||
{
|
||||
return isset($this->abilities[$ability]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a new ability.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param callable|string $callback
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function define($ability, $callback)
|
||||
{
|
||||
if (is_callable($callback)) {
|
||||
$this->abilities[$ability] = $callback;
|
||||
} elseif (is_string($callback) && Str::contains($callback, '@')) {
|
||||
$this->abilities[$ability] = $this->buildAbilityCallback($callback);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Callback must be a callable or a 'Class@method' string.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define abilities for a resource.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $class
|
||||
* @param array $abilities
|
||||
* @return $this
|
||||
*/
|
||||
public function resource($name, $class, array $abilities = null)
|
||||
{
|
||||
$abilities = $abilities ?: [
|
||||
'view' => 'view',
|
||||
'create' => 'create',
|
||||
'update' => 'update',
|
||||
'delete' => 'delete',
|
||||
];
|
||||
|
||||
foreach ($abilities as $ability => $method) {
|
||||
$this->define($name.'.'.$ability, $class.'@'.$method);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ability callback for a callback string.
|
||||
*
|
||||
* @param string $callback
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function buildAbilityCallback($callback)
|
||||
{
|
||||
return function () use ($callback) {
|
||||
list($class, $method) = Str::parseCallback($callback);
|
||||
|
||||
return $this->resolvePolicy($class)->{$method}(...func_get_args());
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a policy class for a given class type.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $policy
|
||||
* @return $this
|
||||
*/
|
||||
public function policy($class, $policy)
|
||||
{
|
||||
$this->policies[$class] = $policy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to run before all Gate checks.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function before(callable $callback)
|
||||
{
|
||||
$this->beforeCallbacks[] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to run after all Gate checks.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function after(callable $callback)
|
||||
{
|
||||
$this->afterCallbacks[] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be granted for the current user.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function allows($ability, $arguments = [])
|
||||
{
|
||||
return $this->check($ability, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be denied for the current user.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function denies($ability, $arguments = [])
|
||||
{
|
||||
return ! $this->allows($ability, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be granted for the current user.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function check($ability, $arguments = [])
|
||||
{
|
||||
try {
|
||||
return (bool) $this->raw($ability, $arguments);
|
||||
} catch (AuthorizationException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be granted for the current user.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function authorize($ability, $arguments = [])
|
||||
{
|
||||
$result = $this->raw($ability, $arguments);
|
||||
|
||||
if ($result instanceof Response) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result ? $this->allow() : $this->deny();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw result from the authorization callback.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
protected function raw($ability, $arguments = [])
|
||||
{
|
||||
if (! $user = $this->resolveUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$arguments = array_wrap($arguments);
|
||||
|
||||
// First we will call the "before" callbacks for the Gate. If any of these give
|
||||
// back a non-null response, we will immediately return that result in order
|
||||
// to let the developers override all checks for some authorization cases.
|
||||
$result = $this->callBeforeCallbacks(
|
||||
$user, $ability, $arguments
|
||||
);
|
||||
|
||||
if (is_null($result)) {
|
||||
$result = $this->callAuthCallback($user, $ability, $arguments);
|
||||
}
|
||||
|
||||
// After calling the authorization callback, we will call the "after" callbacks
|
||||
// that are registered with the Gate, which allows a developer to do logging
|
||||
// if that is required for this application. Then we'll return the result.
|
||||
$this->callAfterCallbacks(
|
||||
$user, $ability, $arguments, $result
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve and call the appropriate authorization callback.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return bool
|
||||
*/
|
||||
protected function callAuthCallback($user, $ability, array $arguments)
|
||||
{
|
||||
$callback = $this->resolveAuthCallback($user, $ability, $arguments);
|
||||
|
||||
return $callback($user, ...$arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call all of the before callbacks and return if a result is given.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return bool|null
|
||||
*/
|
||||
protected function callBeforeCallbacks($user, $ability, array $arguments)
|
||||
{
|
||||
$arguments = array_merge([$user, $ability], [$arguments]);
|
||||
|
||||
foreach ($this->beforeCallbacks as $before) {
|
||||
if (! is_null($result = $before(...$arguments))) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call all of the after callbacks with check result.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @param bool $result
|
||||
* @return void
|
||||
*/
|
||||
protected function callAfterCallbacks($user, $ability, array $arguments, $result)
|
||||
{
|
||||
$arguments = array_merge([$user, $ability, $result], [$arguments]);
|
||||
|
||||
foreach ($this->afterCallbacks as $after) {
|
||||
$after(...$arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the callable for the given ability and arguments.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return callable
|
||||
*/
|
||||
protected function resolveAuthCallback($user, $ability, array $arguments)
|
||||
{
|
||||
if (isset($arguments[0])) {
|
||||
if (! is_null($policy = $this->getPolicyFor($arguments[0]))) {
|
||||
return $this->resolvePolicyCallback($user, $ability, $arguments, $policy);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->abilities[$ability])) {
|
||||
return $this->abilities[$ability];
|
||||
}
|
||||
|
||||
return function () {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a policy instance for a given class.
|
||||
*
|
||||
* @param object|string $class
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPolicyFor($class)
|
||||
{
|
||||
if (is_object($class)) {
|
||||
$class = get_class($class);
|
||||
}
|
||||
|
||||
if (! is_string($class)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($this->policies[$class])) {
|
||||
return $this->resolvePolicy($this->policies[$class]);
|
||||
}
|
||||
|
||||
foreach ($this->policies as $expected => $policy) {
|
||||
if (is_subclass_of($class, $expected)) {
|
||||
return $this->resolvePolicy($policy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a policy class instance of the given type.
|
||||
*
|
||||
* @param object|string $class
|
||||
* @return mixed
|
||||
*/
|
||||
public function resolvePolicy($class)
|
||||
{
|
||||
return $this->container->make($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the callback for a policy check.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @param mixed $policy
|
||||
* @return callable
|
||||
*/
|
||||
protected function resolvePolicyCallback($user, $ability, array $arguments, $policy)
|
||||
{
|
||||
return function () use ($user, $ability, $arguments, $policy) {
|
||||
// This callback will be responsible for calling the policy's before method and
|
||||
// running this policy method if necessary. This is used to when objects are
|
||||
// mapped to policy objects in the user's configurations or on this class.
|
||||
$result = $this->callPolicyBefore(
|
||||
$policy, $user, $ability, $arguments
|
||||
);
|
||||
|
||||
// When we receive a non-null result from this before method, we will return it
|
||||
// as the "final" results. This will allow developers to override the checks
|
||||
// in this policy to return the result for all rules defined in the class.
|
||||
if (! is_null($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$ability = $this->formatAbilityToMethod($ability);
|
||||
|
||||
// If this first argument is a string, that means they are passing a class name
|
||||
// to the policy. We will remove the first argument from this argument array
|
||||
// because this policy already knows what type of models it can authorize.
|
||||
if (isset($arguments[0]) && is_string($arguments[0])) {
|
||||
array_shift($arguments);
|
||||
}
|
||||
|
||||
return is_callable([$policy, $ability])
|
||||
? $policy->{$ability}($user, ...$arguments)
|
||||
: false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the "before" method on the given policy, if applicable.
|
||||
*
|
||||
* @param mixed $policy
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callPolicyBefore($policy, $user, $ability, $arguments)
|
||||
{
|
||||
if (method_exists($policy, 'before')) {
|
||||
return $policy->before($user, $ability, ...$arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the policy ability into a method name.
|
||||
*
|
||||
* @param string $ability
|
||||
* @return string
|
||||
*/
|
||||
protected function formatAbilityToMethod($ability)
|
||||
{
|
||||
return strpos($ability, '-') !== false ? Str::camel($ability) : $ability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a gate instance for the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|mixed $user
|
||||
* @return static
|
||||
*/
|
||||
public function forUser($user)
|
||||
{
|
||||
$callback = function () use ($user) {
|
||||
return $user;
|
||||
};
|
||||
|
||||
return new static(
|
||||
$this->container, $callback, $this->abilities,
|
||||
$this->policies, $this->beforeCallbacks, $this->afterCallbacks
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the user from the user resolver.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function resolveUser()
|
||||
{
|
||||
return call_user_func($this->userResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the defined abilities.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function abilities()
|
||||
{
|
||||
return $this->abilities;
|
||||
}
|
||||
}
|
||||
30
vendor/laravel/framework/src/Illuminate/Auth/Access/HandlesAuthorization.php
vendored
Normal file
30
vendor/laravel/framework/src/Illuminate/Auth/Access/HandlesAuthorization.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
trait HandlesAuthorization
|
||||
{
|
||||
/**
|
||||
* Create a new access response.
|
||||
*
|
||||
* @param string|null $message
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*/
|
||||
protected function allow($message = null)
|
||||
{
|
||||
return new Response($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an unauthorized exception.
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
protected function deny($message = 'This action is unauthorized.')
|
||||
{
|
||||
throw new AuthorizationException($message);
|
||||
}
|
||||
}
|
||||
43
vendor/laravel/framework/src/Illuminate/Auth/Access/Response.php
vendored
Normal file
43
vendor/laravel/framework/src/Illuminate/Auth/Access/Response.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
class Response
|
||||
{
|
||||
/**
|
||||
* The response message.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* Create a new response.
|
||||
*
|
||||
* @param string|null $message
|
||||
*/
|
||||
public function __construct($message = null)
|
||||
{
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response message.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string representation of the message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->message();
|
||||
}
|
||||
}
|
||||
296
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Executable file
296
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Executable file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Contracts\Auth\Factory as FactoryContract;
|
||||
|
||||
class AuthManager implements FactoryContract
|
||||
{
|
||||
use CreatesUserProviders;
|
||||
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The registered custom driver creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customCreators = [];
|
||||
|
||||
/**
|
||||
* The array of created "drivers".
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guards = [];
|
||||
|
||||
/**
|
||||
* The user resolver shared by various services.
|
||||
*
|
||||
* Determines the default user for Gate, Request, and the Authenticatable contract.
|
||||
*
|
||||
* @var \Closure
|
||||
*/
|
||||
protected $userResolver;
|
||||
|
||||
/**
|
||||
* Create a new Auth manager instance.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
$this->userResolver = function ($guard = null) {
|
||||
return $this->guard($guard)->user();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the guard from the local cache.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
|
||||
*/
|
||||
public function guard($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return isset($this->guards[$name])
|
||||
? $this->guards[$name]
|
||||
: $this->guards[$name] = $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (is_null($config)) {
|
||||
throw new InvalidArgumentException("Auth guard [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
if (isset($this->customCreators[$config['driver']])) {
|
||||
return $this->callCustomCreator($name, $config);
|
||||
}
|
||||
|
||||
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
|
||||
|
||||
if (method_exists($this, $driverMethod)) {
|
||||
return $this->{$driverMethod}($name, $config);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Auth guard driver [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a custom driver creator.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $config
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callCustomCreator($name, array $config)
|
||||
{
|
||||
return $this->customCreators[$config['driver']]($this->app, $name, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a session based authentication guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\SessionGuard
|
||||
*/
|
||||
public function createSessionDriver($name, $config)
|
||||
{
|
||||
$provider = $this->createUserProvider($config['provider']);
|
||||
|
||||
$guard = new SessionGuard($name, $provider, $this->app['session.store']);
|
||||
|
||||
// When using the remember me functionality of the authentication services we
|
||||
// will need to be set the encryption instance of the guard, which allows
|
||||
// secure, encrypted cookie values to get generated for those cookies.
|
||||
if (method_exists($guard, 'setCookieJar')) {
|
||||
$guard->setCookieJar($this->app['cookie']);
|
||||
}
|
||||
|
||||
if (method_exists($guard, 'setDispatcher')) {
|
||||
$guard->setDispatcher($this->app['events']);
|
||||
}
|
||||
|
||||
if (method_exists($guard, 'setRequest')) {
|
||||
$guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
|
||||
}
|
||||
|
||||
return $guard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a token based authentication guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\TokenGuard
|
||||
*/
|
||||
public function createTokenDriver($name, $config)
|
||||
{
|
||||
// The token guard implements a basic API token based guard implementation
|
||||
// that takes an API token field from the request and matches it to the
|
||||
// user in the database or another persistence layer where users are.
|
||||
$guard = new TokenGuard(
|
||||
$this->createUserProvider($config['provider']),
|
||||
$this->app['request']
|
||||
);
|
||||
|
||||
$this->app->refresh('request', $guard, 'setRequest');
|
||||
|
||||
return $guard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guard configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["auth.guards.{$name}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default authentication driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['auth.defaults.guard'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default guard driver the factory should serve.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function shouldUse($name)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
$this->setDefaultDriver($name);
|
||||
|
||||
$this->userResolver = function ($name = null) {
|
||||
return $this->guard($name)->user();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default authentication driver name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDriver($name)
|
||||
{
|
||||
$this->app['config']['auth.defaults.guard'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new callback based request guard.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function viaRequest($driver, callable $callback)
|
||||
{
|
||||
return $this->extend($driver, function () use ($callback) {
|
||||
$guard = new RequestGuard($callback, $this->app['request']);
|
||||
|
||||
$this->app->refresh('request', $guard, 'setRequest');
|
||||
|
||||
return $guard;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user resolver callback.
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
public function userResolver()
|
||||
{
|
||||
return $this->userResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the callback to be used to resolve users.
|
||||
*
|
||||
* @param \Closure $userResolver
|
||||
* @return $this
|
||||
*/
|
||||
public function resolveUsersUsing(Closure $userResolver)
|
||||
{
|
||||
$this->userResolver = $userResolver;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function extend($driver, Closure $callback)
|
||||
{
|
||||
$this->customCreators[$driver] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom provider creator Closure.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function provider($name, Closure $callback)
|
||||
{
|
||||
$this->customProviderCreators[$name] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->guard()->{$method}(...$parameters);
|
||||
}
|
||||
}
|
||||
90
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Executable file
90
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Executable file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Auth\Access\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerAuthenticator();
|
||||
|
||||
$this->registerUserResolver();
|
||||
|
||||
$this->registerAccessGate();
|
||||
|
||||
$this->registerRequestRebindHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the authenticator services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerAuthenticator()
|
||||
{
|
||||
$this->app->singleton('auth', function ($app) {
|
||||
// Once the authentication service has actually been requested by the developer
|
||||
// we will set a variable in the application indicating such. This helps us
|
||||
// know that we need to set any queued cookies in the after event later.
|
||||
$app['auth.loaded'] = true;
|
||||
|
||||
return new AuthManager($app);
|
||||
});
|
||||
|
||||
$this->app->singleton('auth.driver', function ($app) {
|
||||
return $app['auth']->guard();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a resolver for the authenticated user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerUserResolver()
|
||||
{
|
||||
$this->app->bind(
|
||||
AuthenticatableContract::class, function ($app) {
|
||||
return call_user_func($app['auth']->userResolver());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the access gate service.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerAccessGate()
|
||||
{
|
||||
$this->app->singleton(GateContract::class, function ($app) {
|
||||
return new Gate($app, function () use ($app) {
|
||||
return call_user_func($app['auth']->userResolver());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a resolver for the authenticated user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerRequestRebindHandler()
|
||||
{
|
||||
$this->app->rebinding('request', function ($app, $request) {
|
||||
$request->setUserResolver(function ($guard = null) use ($app) {
|
||||
return call_user_func($app['auth']->userResolver(), $guard);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
78
vendor/laravel/framework/src/Illuminate/Auth/Authenticatable.php
vendored
Normal file
78
vendor/laravel/framework/src/Illuminate/Auth/Authenticatable.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
trait Authenticatable
|
||||
{
|
||||
/**
|
||||
* The column name of the "remember me" token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rememberTokenName = 'remember_token';
|
||||
|
||||
/**
|
||||
* Get the name of the unique identifier for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthIdentifierName()
|
||||
{
|
||||
return $this->getKeyName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifier()
|
||||
{
|
||||
return $this->{$this->getAuthIdentifierName()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token value for the "remember me" session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberToken()
|
||||
{
|
||||
if (! empty($this->getRememberTokenName())) {
|
||||
return $this->{$this->getRememberTokenName()};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the token value for the "remember me" session.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRememberToken($value)
|
||||
{
|
||||
if (! empty($this->getRememberTokenName())) {
|
||||
$this->{$this->getRememberTokenName()} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the column name for the "remember me" token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberTokenName()
|
||||
{
|
||||
return $this->rememberTokenName;
|
||||
}
|
||||
}
|
||||
39
vendor/laravel/framework/src/Illuminate/Auth/AuthenticationException.php
vendored
Normal file
39
vendor/laravel/framework/src/Illuminate/Auth/AuthenticationException.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AuthenticationException extends Exception
|
||||
{
|
||||
/**
|
||||
* All of the guards that were checked.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guards;
|
||||
|
||||
/**
|
||||
* Create a new authentication exception.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $guards
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($message = 'Unauthenticated.', array $guards = [])
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->guards = $guards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guards that were checked.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function guards()
|
||||
{
|
||||
return $this->guards;
|
||||
}
|
||||
}
|
||||
34
vendor/laravel/framework/src/Illuminate/Auth/Console/ClearResetsCommand.php
vendored
Normal file
34
vendor/laravel/framework/src/Illuminate/Auth/Console/ClearResetsCommand.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ClearResetsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'auth:clear-resets {name? : The name of the password broker}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Flush expired password reset tokens';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->laravel['auth.password']->broker($this->argument('name'))->getRepository()->deleteExpired();
|
||||
|
||||
$this->info('Expired reset tokens cleared!');
|
||||
}
|
||||
}
|
||||
119
vendor/laravel/framework/src/Illuminate/Auth/Console/MakeAuthCommand.php
vendored
Normal file
119
vendor/laravel/framework/src/Illuminate/Auth/Console/MakeAuthCommand.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\DetectsApplicationNamespace;
|
||||
|
||||
class MakeAuthCommand extends Command
|
||||
{
|
||||
use DetectsApplicationNamespace;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make:auth
|
||||
{--views : Only scaffold the authentication views}
|
||||
{--force : Overwrite existing views by default}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Scaffold basic login and registration views and routes';
|
||||
|
||||
/**
|
||||
* The views that need to be exported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $views = [
|
||||
'auth/login.stub' => 'auth/login.blade.php',
|
||||
'auth/register.stub' => 'auth/register.blade.php',
|
||||
'auth/passwords/email.stub' => 'auth/passwords/email.blade.php',
|
||||
'auth/passwords/reset.stub' => 'auth/passwords/reset.blade.php',
|
||||
'layouts/app.stub' => 'layouts/app.blade.php',
|
||||
'home.stub' => 'home.blade.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->createDirectories();
|
||||
|
||||
$this->exportViews();
|
||||
|
||||
if (! $this->option('views')) {
|
||||
file_put_contents(
|
||||
app_path('Http/Controllers/HomeController.php'),
|
||||
$this->compileControllerStub()
|
||||
);
|
||||
|
||||
file_put_contents(
|
||||
base_path('routes/web.php'),
|
||||
file_get_contents(__DIR__.'/stubs/make/routes.stub'),
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
$this->info('Authentication scaffolding generated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the directories for the files.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function createDirectories()
|
||||
{
|
||||
if (! is_dir(resource_path('views/layouts'))) {
|
||||
mkdir(resource_path('views/layouts'), 0755, true);
|
||||
}
|
||||
|
||||
if (! is_dir(resource_path('views/auth/passwords'))) {
|
||||
mkdir(resource_path('views/auth/passwords'), 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the authentication views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function exportViews()
|
||||
{
|
||||
foreach ($this->views as $key => $value) {
|
||||
if (file_exists(resource_path('views/'.$value)) && ! $this->option('force')) {
|
||||
if (! $this->confirm("The [{$value}] view already exists. Do you want to replace it?")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
copy(
|
||||
__DIR__.'/stubs/make/views/'.$key,
|
||||
resource_path('views/'.$value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the HomeController stub.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function compileControllerStub()
|
||||
{
|
||||
return str_replace(
|
||||
'{{namespace}}',
|
||||
$this->getAppNamespace(),
|
||||
file_get_contents(__DIR__.'/stubs/make/controllers/HomeController.stub')
|
||||
);
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/controllers/HomeController.stub
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/controllers/HomeController.stub
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace {{namespace}}Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
4
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/routes.stub
vendored
Normal file
4
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/routes.stub
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/home', 'HomeController@index')->name('home');
|
||||
68
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/login.stub
vendored
Normal file
68
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/login.stub
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Login</div>
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="POST" action="{{ route('login') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password" class="col-md-4 control-label">Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control" name="password" required>
|
||||
|
||||
@if ($errors->has('password'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-8 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Login
|
||||
</button>
|
||||
|
||||
<a class="btn btn-link" href="{{ route('password.request') }}">
|
||||
Forgot Your Password?
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
46
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub
vendored
Normal file
46
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Reset Password</div>
|
||||
<div class="panel-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form class="form-horizontal" method="POST" action="{{ route('password.email') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Send Password Reset Link
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
76
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub
vendored
Normal file
76
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Reset Password</div>
|
||||
|
||||
<div class="panel-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form class="form-horizontal" method="POST" action="{{ route('password.request') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<input type="hidden" name="token" value="{{ $token }}">
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ $email or old('email') }}" required autofocus>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password" class="col-md-4 control-label">Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control" name="password" required>
|
||||
|
||||
@if ($errors->has('password'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
|
||||
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
|
||||
|
||||
@if ($errors->has('password_confirmation'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password_confirmation') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Reset Password
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
76
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/register.stub
vendored
Normal file
76
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/register.stub
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Register</div>
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="POST" action="{{ route('register') }}">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="name" class="col-md-4 control-label">Name</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>
|
||||
|
||||
@if ($errors->has('name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
|
||||
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
|
||||
<label for="password" class="col-md-4 control-label">Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control" name="password" required>
|
||||
|
||||
@if ($errors->has('password'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-6 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Register
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
17
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/home.stub
vendored
Normal file
17
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/home.stub
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Dashboard</div>
|
||||
|
||||
<div class="panel-body">
|
||||
You are logged in!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
80
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
vendored
Normal file
80
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<!-- Styles -->
|
||||
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<nav class="navbar navbar-default navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
|
||||
<!-- Collapsed Hamburger -->
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
|
||||
<span class="sr-only">Toggle Navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
|
||||
<!-- Branding Image -->
|
||||
<a class="navbar-brand" href="{{ url('/') }}">
|
||||
{{ config('app.name', 'Laravel') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="app-navbar-collapse">
|
||||
<!-- Left Side Of Navbar -->
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- Right Side Of Navbar -->
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<!-- Authentication Links -->
|
||||
@if (Auth::guest())
|
||||
<li><a href="{{ route('login') }}">Login</a></li>
|
||||
<li><a href="{{ route('register') }}">Register</a></li>
|
||||
@else
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
{{ Auth::user()->name }} <span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="{{ route('logout') }}"
|
||||
onclick="event.preventDefault();
|
||||
document.getElementById('logout-form').submit();">
|
||||
Logout
|
||||
</a>
|
||||
|
||||
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
|
||||
{{ csrf_field() }}
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@yield('content')
|
||||
</div>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ asset('js/app.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
67
vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php
vendored
Normal file
67
vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
trait CreatesUserProviders
|
||||
{
|
||||
/**
|
||||
* The registered custom provider creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customProviderCreators = [];
|
||||
|
||||
/**
|
||||
* Create the user provider implementation for the driver.
|
||||
*
|
||||
* @param string $provider
|
||||
* @return \Illuminate\Contracts\Auth\UserProvider
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function createUserProvider($provider)
|
||||
{
|
||||
$config = $this->app['config']['auth.providers.'.$provider];
|
||||
|
||||
if (isset($this->customProviderCreators[$config['driver']])) {
|
||||
return call_user_func(
|
||||
$this->customProviderCreators[$config['driver']], $this->app, $config
|
||||
);
|
||||
}
|
||||
|
||||
switch ($config['driver']) {
|
||||
case 'database':
|
||||
return $this->createDatabaseProvider($config);
|
||||
case 'eloquent':
|
||||
return $this->createEloquentProvider($config);
|
||||
default:
|
||||
throw new InvalidArgumentException("Authentication user provider [{$config['driver']}] is not defined.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the database user provider.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\DatabaseUserProvider
|
||||
*/
|
||||
protected function createDatabaseProvider($config)
|
||||
{
|
||||
$connection = $this->app['db']->connection();
|
||||
|
||||
return new DatabaseUserProvider($connection, $this->app['hash'], $config['table']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Eloquent user provider.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\EloquentUserProvider
|
||||
*/
|
||||
protected function createEloquentProvider($config)
|
||||
{
|
||||
return new EloquentUserProvider($this->app['hash'], $config['model']);
|
||||
}
|
||||
}
|
||||
146
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Executable file
146
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Executable file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
|
||||
class DatabaseUserProvider implements UserProvider
|
||||
{
|
||||
/**
|
||||
* The active database connection.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* The hasher implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
protected $hasher;
|
||||
|
||||
/**
|
||||
* The table containing the users.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* Create a new database user provider.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $conn
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param string $table
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ConnectionInterface $conn, HasherContract $hasher, $table)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
$this->table = $table;
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveById($identifier)
|
||||
{
|
||||
$user = $this->conn->table($this->table)->find($identifier);
|
||||
|
||||
return $this->getGenericUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier and "remember me" token.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @param string $token
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByToken($identifier, $token)
|
||||
{
|
||||
$user = $this->conn->table($this->table)
|
||||
->where('id', $identifier)
|
||||
->where('remember_token', $token)
|
||||
->first();
|
||||
|
||||
return $this->getGenericUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the "remember me" token for the given user in storage.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function updateRememberToken(UserContract $user, $token)
|
||||
{
|
||||
$this->conn->table($this->table)
|
||||
->where('id', $user->getAuthIdentifier())
|
||||
->update(['remember_token' => $token]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByCredentials(array $credentials)
|
||||
{
|
||||
// First we will add each credential element to the query as a where clause.
|
||||
// Then we can execute the query and, if we found a user, return it in a
|
||||
// generic "user" object that will be utilized by the Guard instances.
|
||||
$query = $this->conn->table($this->table);
|
||||
|
||||
foreach ($credentials as $key => $value) {
|
||||
if (! Str::contains($key, 'password')) {
|
||||
$query->where($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Now we are ready to execute the query to see if we have an user matching
|
||||
// the given credentials. If not, we will just return nulls and indicate
|
||||
// that there are no matching users for these given credential arrays.
|
||||
$user = $query->first();
|
||||
|
||||
return $this->getGenericUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the generic user.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @return \Illuminate\Auth\GenericUser|null
|
||||
*/
|
||||
protected function getGenericUser($user)
|
||||
{
|
||||
if (! is_null($user)) {
|
||||
return new GenericUser((array) $user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user against the given credentials.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateCredentials(UserContract $user, array $credentials)
|
||||
{
|
||||
return $this->hasher->check(
|
||||
$credentials['password'], $user->getAuthPassword()
|
||||
);
|
||||
}
|
||||
}
|
||||
188
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Executable file
188
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Executable file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
|
||||
class EloquentUserProvider implements UserProvider
|
||||
{
|
||||
/**
|
||||
* The hasher implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
protected $hasher;
|
||||
|
||||
/**
|
||||
* The Eloquent user model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Create a new database user provider.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param string $model
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(HasherContract $hasher, $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveById($identifier)
|
||||
{
|
||||
$model = $this->createModel();
|
||||
|
||||
return $model->newQuery()
|
||||
->where($model->getAuthIdentifierName(), $identifier)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier and "remember me" token.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @param string $token
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByToken($identifier, $token)
|
||||
{
|
||||
$model = $this->createModel();
|
||||
|
||||
return $model->newQuery()
|
||||
->where($model->getAuthIdentifierName(), $identifier)
|
||||
->where($model->getRememberTokenName(), $token)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the "remember me" token for the given user in storage.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function updateRememberToken(UserContract $user, $token)
|
||||
{
|
||||
$user->setRememberToken($token);
|
||||
|
||||
$timestamps = $user->timestamps;
|
||||
|
||||
$user->timestamps = false;
|
||||
|
||||
$user->save();
|
||||
|
||||
$user->timestamps = $timestamps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByCredentials(array $credentials)
|
||||
{
|
||||
if (empty($credentials)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First we will add each credential element to the query as a where clause.
|
||||
// Then we can execute the query and, if we found a user, return it in a
|
||||
// Eloquent User "model" that will be utilized by the Guard instances.
|
||||
$query = $this->createModel()->newQuery();
|
||||
|
||||
foreach ($credentials as $key => $value) {
|
||||
if (! Str::contains($key, 'password')) {
|
||||
$query->where($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user against the given credentials.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateCredentials(UserContract $user, array $credentials)
|
||||
{
|
||||
$plain = $credentials['password'];
|
||||
|
||||
return $this->hasher->check($plain, $user->getAuthPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function createModel()
|
||||
{
|
||||
$class = '\\'.ltrim($this->model, '\\');
|
||||
|
||||
return new $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hasher implementation.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
public function getHasher()
|
||||
{
|
||||
return $this->hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the hasher implementation.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @return $this
|
||||
*/
|
||||
public function setHasher(HasherContract $hasher)
|
||||
{
|
||||
$this->hasher = $hasher;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the Eloquent user model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the Eloquent user model.
|
||||
*
|
||||
* @param string $model
|
||||
* @return $this
|
||||
*/
|
||||
public function setModel($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
32
vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php
vendored
Normal file
32
vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
class Attempting
|
||||
{
|
||||
/**
|
||||
* The credentials for the user.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $credentials;
|
||||
|
||||
/**
|
||||
* Indicates if the user should be "remembered".
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $remember;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
*/
|
||||
public function __construct($credentials, $remember)
|
||||
{
|
||||
$this->remember = $remember;
|
||||
$this->credentials = $credentials;
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Authenticated
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
32
vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php
vendored
Normal file
32
vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
class Failed
|
||||
{
|
||||
/**
|
||||
* The user the attempter was trying to authenticate as.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* The credentials provided by the attempter.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $credentials;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param array $credentials
|
||||
*/
|
||||
public function __construct($user, $credentials)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->credentials = $credentials;
|
||||
}
|
||||
}
|
||||
26
vendor/laravel/framework/src/Illuminate/Auth/Events/Lockout.php
vendored
Normal file
26
vendor/laravel/framework/src/Illuminate/Auth/Events/Lockout.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Lockout
|
||||
{
|
||||
/**
|
||||
* The throttled request.
|
||||
*
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
||||
37
vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php
vendored
Normal file
37
vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Login
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Indicates if the user should be "remembered".
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $remember;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user, $remember)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->remember = $remember;
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Logout
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Registered.php
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Registered.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Registered
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
134
vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
vendored
Executable file
134
vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
vendored
Executable file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
|
||||
class GenericUser implements UserContract
|
||||
{
|
||||
/**
|
||||
* All of the user's attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes;
|
||||
|
||||
/**
|
||||
* Create a new generic User object.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $attributes)
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the unique identifier for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthIdentifierName()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifier()
|
||||
{
|
||||
$name = $this->getAuthIdentifierName();
|
||||
|
||||
return $this->attributes[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthPassword()
|
||||
{
|
||||
return $this->attributes['password'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "remember me" token value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberToken()
|
||||
{
|
||||
return $this->attributes[$this->getRememberTokenName()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "remember me" token value.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRememberToken($value)
|
||||
{
|
||||
$this->attributes[$this->getRememberTokenName()] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the column name for the "remember me" token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberTokenName()
|
||||
{
|
||||
return 'remember_token';
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically access the user's attributes.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically set an attribute on the user.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically check if a value is set on the user.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return isset($this->attributes[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically unset a value on the user.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
unset($this->attributes[$key]);
|
||||
}
|
||||
}
|
||||
86
vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
vendored
Normal file
86
vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
|
||||
/**
|
||||
* These methods are typically the same across all guards.
|
||||
*/
|
||||
trait GuardHelpers
|
||||
{
|
||||
/**
|
||||
* The currently authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* The user provider implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\UserProvider
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* Determine if the current user is authenticated.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
if (! is_null($user = $this->user())) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
throw new AuthenticationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current user is authenticated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
return ! is_null($this->user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current user is a guest.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function guest()
|
||||
{
|
||||
return ! $this->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function id()
|
||||
{
|
||||
if ($this->user()) {
|
||||
return $this->user()->getAuthIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(AuthenticatableContract $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
68
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
vendored
Normal file
68
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
/**
|
||||
* The authentication factory instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Factory
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Factory $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Auth $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string[] ...$guards
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
{
|
||||
$this->authenticate($guards);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is logged in to any of the given guards.
|
||||
*
|
||||
* @param array $guards
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
protected function authenticate(array $guards)
|
||||
{
|
||||
if (empty($guards)) {
|
||||
return $this->auth->authenticate();
|
||||
}
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if ($this->auth->guard($guard)->check()) {
|
||||
return $this->auth->shouldUse($guard);
|
||||
}
|
||||
}
|
||||
|
||||
throw new AuthenticationException('Unauthenticated.', $guards);
|
||||
}
|
||||
}
|
||||
40
vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
vendored
Normal file
40
vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Factory as AuthFactory;
|
||||
|
||||
class AuthenticateWithBasicAuth
|
||||
{
|
||||
/**
|
||||
* The guard factory instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Factory
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Factory $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(AuthFactory $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
return $this->auth->guard($guard)->basic() ?: $next($request);
|
||||
}
|
||||
}
|
||||
100
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
vendored
Normal file
100
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Auth\Access\Gate;
|
||||
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||
|
||||
class Authorize
|
||||
{
|
||||
/**
|
||||
* The authentication factory instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Factory
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* The gate instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Access\Gate
|
||||
*/
|
||||
protected $gate;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Factory $auth
|
||||
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Auth $auth, Gate $gate)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->gate = $gate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string $ability
|
||||
* @param array|null $models
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function handle($request, Closure $next, $ability, ...$models)
|
||||
{
|
||||
$this->auth->authenticate();
|
||||
|
||||
$this->gate->authorize($ability, $this->getGateArguments($request, $models));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the arguments parameter for the gate.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param array|null $models
|
||||
* @return array|string|\Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
protected function getGateArguments($request, $models)
|
||||
{
|
||||
if (is_null($models)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return collect($models)->map(function ($model) use ($request) {
|
||||
return $model instanceof Model ? $model : $this->getModel($request, $model);
|
||||
})->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model to authorize.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $model
|
||||
* @return string|\Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
protected function getModel($request, $model)
|
||||
{
|
||||
return $this->isClassName($model) ? $model : $request->route($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given string looks like a fully qualified class name.
|
||||
*
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function isClassName($value)
|
||||
{
|
||||
return strpos($value, '\\') !== false;
|
||||
}
|
||||
}
|
||||
52
vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
vendored
Normal file
52
vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Notifications;
|
||||
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ResetPassword extends Notification
|
||||
{
|
||||
/**
|
||||
* The password reset token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* Create a notification instance.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array|string
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('You are receiving this email because we received a password reset request for your account.')
|
||||
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
|
||||
->line('If you did not request a password reset, no further action is required.');
|
||||
}
|
||||
}
|
||||
29
vendor/laravel/framework/src/Illuminate/Auth/Passwords/CanResetPassword.php
vendored
Normal file
29
vendor/laravel/framework/src/Illuminate/Auth/Passwords/CanResetPassword.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
|
||||
trait CanResetPassword
|
||||
{
|
||||
/**
|
||||
* Get the e-mail address where password reset links are sent.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailForPasswordReset()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
}
|
||||
204
vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
vendored
Executable file
204
vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
vendored
Executable file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
class DatabaseTokenRepository implements TokenRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* The database connection instance.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* The Hasher implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
protected $hasher;
|
||||
|
||||
/**
|
||||
* The token database table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* The hashing key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $hashKey;
|
||||
|
||||
/**
|
||||
* The number of seconds a token should last.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $expires;
|
||||
|
||||
/**
|
||||
* Create a new token repository instance.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $connection
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param string $table
|
||||
* @param string $hashKey
|
||||
* @param int $expires
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ConnectionInterface $connection, HasherContract $hasher,
|
||||
$table, $hashKey, $expires = 60)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->hasher = $hasher;
|
||||
$this->hashKey = $hashKey;
|
||||
$this->expires = $expires * 60;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new token record.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return string
|
||||
*/
|
||||
public function create(CanResetPasswordContract $user)
|
||||
{
|
||||
$email = $user->getEmailForPasswordReset();
|
||||
|
||||
$this->deleteExisting($user);
|
||||
|
||||
// We will create a new, random token for the user so that we can e-mail them
|
||||
// a safe link to the password reset form. Then we will insert a record in
|
||||
// the database so that we can verify the token within the actual reset.
|
||||
$token = $this->createNewToken();
|
||||
|
||||
$this->getTable()->insert($this->getPayload($email, $token));
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all existing reset tokens from the database.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return int
|
||||
*/
|
||||
protected function deleteExisting(CanResetPasswordContract $user)
|
||||
{
|
||||
return $this->getTable()->where('email', $user->getEmailForPasswordReset())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the record payload for the table.
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $token
|
||||
* @return array
|
||||
*/
|
||||
protected function getPayload($email, $token)
|
||||
{
|
||||
return ['email' => $email, 'token' => $this->hasher->make($token), 'created_at' => new Carbon];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a token record exists and is valid.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @param string $token
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(CanResetPasswordContract $user, $token)
|
||||
{
|
||||
$record = (array) $this->getTable()->where(
|
||||
'email', $user->getEmailForPasswordReset()
|
||||
)->first();
|
||||
|
||||
return $record &&
|
||||
! $this->tokenExpired($record['created_at']) &&
|
||||
$this->hasher->check($token, $record['token']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the token has expired.
|
||||
*
|
||||
* @param string $createdAt
|
||||
* @return bool
|
||||
*/
|
||||
protected function tokenExpired($createdAt)
|
||||
{
|
||||
return Carbon::parse($createdAt)->addSeconds($this->expires)->isPast();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a token record by user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return void
|
||||
*/
|
||||
public function delete(CanResetPasswordContract $user)
|
||||
{
|
||||
$this->deleteExisting($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete expired tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteExpired()
|
||||
{
|
||||
$expiredAt = Carbon::now()->subSeconds($this->expires);
|
||||
|
||||
$this->getTable()->where('created_at', '<', $expiredAt)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new token for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createNewToken()
|
||||
{
|
||||
return hash_hmac('sha256', Str::random(40), $this->hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the database connection instance.
|
||||
*
|
||||
* @return \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a new database query against the table.
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
*/
|
||||
protected function getTable()
|
||||
{
|
||||
return $this->connection->table($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hasher instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
public function getHasher()
|
||||
{
|
||||
return $this->hasher;
|
||||
}
|
||||
}
|
||||
242
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Executable file
242
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Executable file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Arr;
|
||||
use UnexpectedValueException;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker as PasswordBrokerContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
class PasswordBroker implements PasswordBrokerContract
|
||||
{
|
||||
/**
|
||||
* The password token repository.
|
||||
*
|
||||
* @var \Illuminate\Auth\Passwords\TokenRepositoryInterface
|
||||
*/
|
||||
protected $tokens;
|
||||
|
||||
/**
|
||||
* The user provider implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\UserProvider
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
/**
|
||||
* The custom password validator callback.
|
||||
*
|
||||
* @var \Closure
|
||||
*/
|
||||
protected $passwordValidator;
|
||||
|
||||
/**
|
||||
* Create a new password broker instance.
|
||||
*
|
||||
* @param \Illuminate\Auth\Passwords\TokenRepositoryInterface $tokens
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $users
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TokenRepositoryInterface $tokens,
|
||||
UserProvider $users)
|
||||
{
|
||||
$this->users = $users;
|
||||
$this->tokens = $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a password reset link to a user.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return string
|
||||
*/
|
||||
public function sendResetLink(array $credentials)
|
||||
{
|
||||
// First we will check to see if we found a user at the given credentials and
|
||||
// if we did not we will redirect back to this current URI with a piece of
|
||||
// "flash" data in the session to indicate to the developers the errors.
|
||||
$user = $this->getUser($credentials);
|
||||
|
||||
if (is_null($user)) {
|
||||
return static::INVALID_USER;
|
||||
}
|
||||
|
||||
// Once we have the reset token, we are ready to send the message out to this
|
||||
// user with a link to reset their password. We will then redirect back to
|
||||
// the current URI having nothing set in the session to indicate errors.
|
||||
$user->sendPasswordResetNotification(
|
||||
$this->tokens->create($user)
|
||||
);
|
||||
|
||||
return static::RESET_LINK_SENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the password for the given token.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset(array $credentials, Closure $callback)
|
||||
{
|
||||
// If the responses from the validate method is not a user instance, we will
|
||||
// assume that it is a redirect and simply return it from this method and
|
||||
// the user is properly redirected having an error message on the post.
|
||||
$user = $this->validateReset($credentials);
|
||||
|
||||
if (! $user instanceof CanResetPasswordContract) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
$password = $credentials['password'];
|
||||
|
||||
// Once the reset has been validated, we'll call the given callback with the
|
||||
// new password. This gives the user an opportunity to store the password
|
||||
// in their persistent storage. Then we'll delete the token and return.
|
||||
$callback($user, $password);
|
||||
|
||||
$this->tokens->delete($user);
|
||||
|
||||
return static::PASSWORD_RESET;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a password reset for the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\CanResetPassword
|
||||
*/
|
||||
protected function validateReset(array $credentials)
|
||||
{
|
||||
if (is_null($user = $this->getUser($credentials))) {
|
||||
return static::INVALID_USER;
|
||||
}
|
||||
|
||||
if (! $this->validateNewPassword($credentials)) {
|
||||
return static::INVALID_PASSWORD;
|
||||
}
|
||||
|
||||
if (! $this->tokens->exists($user, $credentials['token'])) {
|
||||
return static::INVALID_TOKEN;
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom password validator.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public function validator(Closure $callback)
|
||||
{
|
||||
$this->passwordValidator = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the passwords match for the request.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateNewPassword(array $credentials)
|
||||
{
|
||||
if (isset($this->passwordValidator)) {
|
||||
list($password, $confirm) = [
|
||||
$credentials['password'],
|
||||
$credentials['password_confirmation'],
|
||||
];
|
||||
|
||||
return call_user_func(
|
||||
$this->passwordValidator, $credentials
|
||||
) && $password === $confirm;
|
||||
}
|
||||
|
||||
return $this->validatePasswordWithDefaults($credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the passwords are valid for the request.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
protected function validatePasswordWithDefaults(array $credentials)
|
||||
{
|
||||
list($password, $confirm) = [
|
||||
$credentials['password'],
|
||||
$credentials['password_confirmation'],
|
||||
];
|
||||
|
||||
return $password === $confirm && mb_strlen($password) >= 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user for the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\CanResetPassword
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function getUser(array $credentials)
|
||||
{
|
||||
$credentials = Arr::except($credentials, ['token']);
|
||||
|
||||
$user = $this->users->retrieveByCredentials($credentials);
|
||||
|
||||
if ($user && ! $user instanceof CanResetPasswordContract) {
|
||||
throw new UnexpectedValueException('User must implement CanResetPassword interface.');
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new password reset token for the given user.
|
||||
*
|
||||
* @param CanResetPasswordContract $user
|
||||
* @return string
|
||||
*/
|
||||
public function createToken(CanResetPasswordContract $user)
|
||||
{
|
||||
return $this->tokens->create($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete password reset tokens of the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return void
|
||||
*/
|
||||
public function deleteToken(CanResetPasswordContract $user)
|
||||
{
|
||||
$this->tokens->delete($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the given password reset token.
|
||||
*
|
||||
* @param CanResetPasswordContract $user
|
||||
* @param string $token
|
||||
* @return bool
|
||||
*/
|
||||
public function tokenExists(CanResetPasswordContract $user, $token)
|
||||
{
|
||||
return $this->tokens->exists($user, $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password reset token repository implementation.
|
||||
*
|
||||
* @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
|
||||
*/
|
||||
public function getRepository()
|
||||
{
|
||||
return $this->tokens;
|
||||
}
|
||||
}
|
||||
144
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
vendored
Normal file
144
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Contracts\Auth\PasswordBrokerFactory as FactoryContract;
|
||||
|
||||
class PasswordBrokerManager implements FactoryContract
|
||||
{
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The array of created "drivers".
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $brokers = [];
|
||||
|
||||
/**
|
||||
* Create a new PasswordBroker manager instance.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the broker from the local cache.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*/
|
||||
public function broker($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return isset($this->brokers[$name])
|
||||
? $this->brokers[$name]
|
||||
: $this->brokers[$name] = $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given broker.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (is_null($config)) {
|
||||
throw new InvalidArgumentException("Password resetter [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
// The password broker uses a token repository to validate tokens and send user
|
||||
// password e-mails, as well as validating that password reset process as an
|
||||
// aggregate service of sorts providing a convenient interface for resets.
|
||||
return new PasswordBroker(
|
||||
$this->createTokenRepository($config),
|
||||
$this->app['auth']->createUserProvider($config['provider'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a token repository instance based on the given configuration.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
|
||||
*/
|
||||
protected function createTokenRepository(array $config)
|
||||
{
|
||||
$key = $this->app['config']['app.key'];
|
||||
|
||||
if (Str::startsWith($key, 'base64:')) {
|
||||
$key = base64_decode(substr($key, 7));
|
||||
}
|
||||
|
||||
$connection = isset($config['connection']) ? $config['connection'] : null;
|
||||
|
||||
return new DatabaseTokenRepository(
|
||||
$this->app['db']->connection($connection),
|
||||
$this->app['hash'],
|
||||
$config['table'],
|
||||
$key,
|
||||
$config['expire']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password broker configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["auth.passwords.{$name}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default password broker name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['auth.defaults.passwords'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default password broker name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDriver($name)
|
||||
{
|
||||
$this->app['config']['auth.defaults.passwords'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->broker()->{$method}(...$parameters);
|
||||
}
|
||||
}
|
||||
51
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Executable file
51
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class PasswordResetServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = true;
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerPasswordBroker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the password broker instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerPasswordBroker()
|
||||
{
|
||||
$this->app->singleton('auth.password', function ($app) {
|
||||
return new PasswordBrokerManager($app);
|
||||
});
|
||||
|
||||
$this->app->bind('auth.password.broker', function ($app) {
|
||||
return $app->make('auth.password')->broker();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return ['auth.password', 'auth.password.broker'];
|
||||
}
|
||||
}
|
||||
40
vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
vendored
Executable file
40
vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
interface TokenRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new token.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return string
|
||||
*/
|
||||
public function create(CanResetPasswordContract $user);
|
||||
|
||||
/**
|
||||
* Determine if a token record exists and is valid.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @param string $token
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(CanResetPasswordContract $user, $token);
|
||||
|
||||
/**
|
||||
* Delete a token record.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return void
|
||||
*/
|
||||
public function delete(CanResetPasswordContract $user);
|
||||
|
||||
/**
|
||||
* Delete expired tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteExpired();
|
||||
}
|
||||
78
vendor/laravel/framework/src/Illuminate/Auth/Recaller.php
vendored
Normal file
78
vendor/laravel/framework/src/Illuminate/Auth/Recaller.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Recaller
|
||||
{
|
||||
/**
|
||||
* The "recaller" / "remember me" cookie string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $recaller;
|
||||
|
||||
/**
|
||||
* Create a new recaller instance.
|
||||
*
|
||||
* @param string $recaller
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($recaller)
|
||||
{
|
||||
$this->recaller = $recaller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user ID from the recaller.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function id()
|
||||
{
|
||||
return explode('|', $this->recaller, 2)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "remember token" token from the recaller.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function token()
|
||||
{
|
||||
return explode('|', $this->recaller, 2)[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the recaller is valid.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return $this->properString() && $this->hasBothSegments();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the recaller is an invalid string.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function properString()
|
||||
{
|
||||
return is_string($this->recaller) && Str::contains($this->recaller, '|');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the recaller has both segments.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasBothSegments()
|
||||
{
|
||||
$segments = explode('|', $this->recaller);
|
||||
|
||||
return count($segments) == 2 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
|
||||
}
|
||||
}
|
||||
84
vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php
vendored
Normal file
84
vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
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
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(callable $callback, Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = [])
|
||||
{
|
||||
return ! is_null((new static(
|
||||
$this->callback, $credentials['request']
|
||||
))->user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current request instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
775
vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php
vendored
Normal file
775
vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php
vendored
Normal file
@@ -0,0 +1,775 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use RuntimeException;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Contracts\Session\Session;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Illuminate\Contracts\Auth\SupportsBasicAuth;
|
||||
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
|
||||
class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
{
|
||||
use GuardHelpers, Macroable;
|
||||
|
||||
/**
|
||||
* The name of the Guard. Typically "session".
|
||||
*
|
||||
* Corresponds to guard name in authentication configuration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The user we last attempted to retrieve.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $lastAttempted;
|
||||
|
||||
/**
|
||||
* Indicates if the user was authenticated via a recaller cookie.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $viaRemember = false;
|
||||
|
||||
/**
|
||||
* The session used by the guard.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Session\Session
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* The Illuminate cookie creator service.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Cookie\QueueingFactory
|
||||
*/
|
||||
protected $cookie;
|
||||
|
||||
/**
|
||||
* The request instance.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The event dispatcher instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* Indicates if the logout method has been called.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $loggedOut = false;
|
||||
|
||||
/**
|
||||
* Indicates if a token user retrieval has been attempted.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $recallAttempted = false;
|
||||
|
||||
/**
|
||||
* Create a new authentication guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $provider
|
||||
* @param \Illuminate\Contracts\Session\Session $session
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name,
|
||||
UserProvider $provider,
|
||||
Session $session,
|
||||
Request $request = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->session = $session;
|
||||
$this->request = $request;
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
if ($this->loggedOut) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
$id = $this->session->get($this->getName());
|
||||
|
||||
// First we will try to load the user using the identifier in the session if
|
||||
// one exists. Otherwise we will check for a "remember me" cookie in this
|
||||
// request, and if one exists, attempt to retrieve the user using that.
|
||||
$user = null;
|
||||
|
||||
if (! is_null($id)) {
|
||||
if ($user = $this->provider->retrieveById($id)) {
|
||||
$this->fireAuthenticatedEvent($user);
|
||||
}
|
||||
}
|
||||
|
||||
// If the user is null, but we decrypt a "recaller" cookie we can attempt to
|
||||
// pull the user data on that cookie which serves as a remember cookie on
|
||||
// the application. Once we have a user we can return it to the caller.
|
||||
$recaller = $this->recaller();
|
||||
|
||||
if (is_null($user) && ! is_null($recaller)) {
|
||||
$user = $this->userFromRecaller($recaller);
|
||||
|
||||
if ($user) {
|
||||
$this->updateSession($user->getAuthIdentifier());
|
||||
|
||||
$this->fireLoginEvent($user, true);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pull a user from the repository by its "remember me" cookie token.
|
||||
*
|
||||
* @param \Illuminate\Auth\Recaller $recaller
|
||||
* @return mixed
|
||||
*/
|
||||
protected function userFromRecaller($recaller)
|
||||
{
|
||||
if (! $recaller->valid() || $this->recallAttempted) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user is null, but we decrypt a "recaller" cookie we can attempt to
|
||||
// pull the user data on that cookie which serves as a remember cookie on
|
||||
// the application. Once we have a user we can return it to the caller.
|
||||
$this->recallAttempted = true;
|
||||
|
||||
$this->viaRemember = ! is_null($user = $this->provider->retrieveByToken(
|
||||
$recaller->id(), $recaller->token()
|
||||
));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the decrypted recaller cookie for the request.
|
||||
*
|
||||
* @return \Illuminate\Auth\Recaller|null
|
||||
*/
|
||||
protected function recaller()
|
||||
{
|
||||
if (is_null($this->request)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($recaller = $this->request->cookies->get($this->getRecallerName())) {
|
||||
return new Recaller($recaller);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function id()
|
||||
{
|
||||
if ($this->loggedOut) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->user()
|
||||
? $this->user()->getAuthIdentifier()
|
||||
: $this->session->get($this->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a user into the application without sessions or cookies.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function once(array $credentials = [])
|
||||
{
|
||||
$this->fireAttemptEvent($credentials);
|
||||
|
||||
if ($this->validate($credentials)) {
|
||||
$this->setUser($this->lastAttempted);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given user ID into the application without sessions or cookies.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|false
|
||||
*/
|
||||
public function onceUsingId($id)
|
||||
{
|
||||
if (! is_null($user = $this->provider->retrieveById($id))) {
|
||||
$this->setUser($user);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = [])
|
||||
{
|
||||
$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
|
||||
|
||||
return $this->hasValidCredentials($user, $credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate using HTTP Basic Auth.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
*/
|
||||
public function basic($field = 'email', $extraConditions = [])
|
||||
{
|
||||
if ($this->check()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If a username is set on the HTTP basic request, we will return out without
|
||||
// interrupting the request lifecycle. Otherwise, we'll need to generate a
|
||||
// request indicating that the given credentials were invalid for login.
|
||||
if ($this->attemptBasic($this->getRequest(), $field, $extraConditions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->failedBasicResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a stateless HTTP Basic login attempt.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
*/
|
||||
public function onceBasic($field = 'email', $extraConditions = [])
|
||||
{
|
||||
$credentials = $this->basicCredentials($this->getRequest(), $field);
|
||||
|
||||
if (! $this->once(array_merge($credentials, $extraConditions))) {
|
||||
return $this->failedBasicResponse();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate using basic authentication.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return bool
|
||||
*/
|
||||
protected function attemptBasic(Request $request, $field, $extraConditions = [])
|
||||
{
|
||||
if (! $request->getUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->attempt(array_merge(
|
||||
$this->basicCredentials($request, $field), $extraConditions
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the credential array for a HTTP Basic request.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
protected function basicCredentials(Request $request, $field)
|
||||
{
|
||||
return [$field => $request->getUser(), 'password' => $request->getPassword()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for basic authentication.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function failedBasicResponse()
|
||||
{
|
||||
return new Response('Invalid credentials.', 401, ['WWW-Authenticate' => 'Basic']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate a user using the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @return bool
|
||||
*/
|
||||
public function attempt(array $credentials = [], $remember = false)
|
||||
{
|
||||
$this->fireAttemptEvent($credentials, $remember);
|
||||
|
||||
$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
|
||||
|
||||
// If an implementation of UserInterface was returned, we'll ask the provider
|
||||
// to validate the user against the given credentials, and if they are in
|
||||
// fact valid we'll log the users into the application and return true.
|
||||
if ($this->hasValidCredentials($user, $credentials)) {
|
||||
$this->login($user, $remember);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the authentication attempt fails we will fire an event so that the user
|
||||
// may be notified of any suspicious attempts to access their account from
|
||||
// an unrecognized user. A developer may listen to this event as needed.
|
||||
$this->fireFailedEvent($user, $credentials);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user matches the credentials.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasValidCredentials($user, $credentials)
|
||||
{
|
||||
return ! is_null($user) && $this->provider->validateCredentials($user, $credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given user ID into the application.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param bool $remember
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|false
|
||||
*/
|
||||
public function loginUsingId($id, $remember = false)
|
||||
{
|
||||
if (! is_null($user = $this->provider->retrieveById($id))) {
|
||||
$this->login($user, $remember);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a user into the application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
public function login(AuthenticatableContract $user, $remember = false)
|
||||
{
|
||||
$this->updateSession($user->getAuthIdentifier());
|
||||
|
||||
// If the user should be permanently "remembered" by the application we will
|
||||
// queue a permanent cookie that contains the encrypted copy of the user
|
||||
// identifier. We will then decrypt this later to retrieve the users.
|
||||
if ($remember) {
|
||||
$this->ensureRememberTokenIsSet($user);
|
||||
|
||||
$this->queueRecallerCookie($user);
|
||||
}
|
||||
|
||||
// If we have an event dispatcher instance set we will fire an event so that
|
||||
// any listeners will hook into the authentication events and run actions
|
||||
// based on the login and logout events fired from the guard instances.
|
||||
$this->fireLoginEvent($user, $remember);
|
||||
|
||||
$this->setUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the session with the given ID.
|
||||
*
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
protected function updateSession($id)
|
||||
{
|
||||
$this->session->put($this->getName(), $id);
|
||||
|
||||
$this->session->migrate(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new "remember me" token for the user if one doesn't already exist.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function ensureRememberTokenIsSet(AuthenticatableContract $user)
|
||||
{
|
||||
if (empty($user->getRememberToken())) {
|
||||
$this->cycleRememberToken($user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue the recaller cookie into the cookie jar.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function queueRecallerCookie(AuthenticatableContract $user)
|
||||
{
|
||||
$this->getCookieJar()->queue($this->createRecaller(
|
||||
$user->getAuthIdentifier().'|'.$user->getRememberToken()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a "remember me" cookie for a given ID.
|
||||
*
|
||||
* @param string $value
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
protected function createRecaller($value)
|
||||
{
|
||||
return $this->getCookieJar()->forever($this->getRecallerName(), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
// If we have an event dispatcher instance, we can fire off the logout event
|
||||
// so any further processing can be done. This allows the developer to be
|
||||
// listening for anytime a user signs out of this application manually.
|
||||
$this->clearUserDataFromStorage();
|
||||
|
||||
if (! is_null($this->user)) {
|
||||
$this->cycleRememberToken($user);
|
||||
}
|
||||
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Logout($user));
|
||||
}
|
||||
|
||||
// Once we have fired the logout event we will clear the users out of memory
|
||||
// so they are no longer available as the user is no longer considered as
|
||||
// being signed into this application and should not be available here.
|
||||
$this->user = null;
|
||||
|
||||
$this->loggedOut = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user data from the session and cookies.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function clearUserDataFromStorage()
|
||||
{
|
||||
$this->session->remove($this->getName());
|
||||
|
||||
if (! is_null($this->recaller())) {
|
||||
$this->getCookieJar()->queue($this->getCookieJar()
|
||||
->forget($this->getRecallerName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the "remember me" token for the user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function cycleRememberToken(AuthenticatableContract $user)
|
||||
{
|
||||
$user->setRememberToken($token = Str::random(60));
|
||||
|
||||
$this->provider->updateRememberToken($user, $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an authentication attempt event listener.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @return void
|
||||
*/
|
||||
public function attempting($callback)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->listen(Events\Attempting::class, $callback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the attempt event with the arguments.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
protected function fireAttemptEvent(array $credentials, $remember = false)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Attempting(
|
||||
$credentials, $remember
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the login event if the dispatcher is set.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
protected function fireLoginEvent($user, $remember = false)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Login($user, $remember));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the authenticated event if the dispatcher is set.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function fireAuthenticatedEvent($user)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Authenticated($user));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the failed authentication attempt event with the given arguments.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param array $credentials
|
||||
* @return void
|
||||
*/
|
||||
protected function fireFailedEvent($user, array $credentials)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Failed($user, $credentials));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last user we attempted to authenticate.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public function getLastAttempted()
|
||||
{
|
||||
return $this->lastAttempted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a unique identifier for the auth session value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'login_'.$this->name.'_'.sha1(static::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the cookie used to store the "recaller".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRecallerName()
|
||||
{
|
||||
return 'remember_'.$this->name.'_'.sha1(static::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user was authenticated via "remember me" cookie.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function viaRemember()
|
||||
{
|
||||
return $this->viaRemember;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookie creator instance used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Cookie\QueueingFactory
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getCookieJar()
|
||||
{
|
||||
if (! isset($this->cookie)) {
|
||||
throw new RuntimeException('Cookie jar has not been set.');
|
||||
}
|
||||
|
||||
return $this->cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cookie creator instance used by the guard.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cookie\QueueingFactory $cookie
|
||||
* @return void
|
||||
*/
|
||||
public function setCookieJar(CookieJar $cookie)
|
||||
{
|
||||
$this->cookie = $cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event dispatcher instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the event dispatcher instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function setDispatcher(Dispatcher $events)
|
||||
{
|
||||
$this->events = $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session store used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Session\Store
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user provider used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\UserProvider
|
||||
*/
|
||||
public function getProvider()
|
||||
{
|
||||
return $this->provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user provider used by the guard.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $provider
|
||||
* @return void
|
||||
*/
|
||||
public function setProvider(UserProvider $provider)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the currently cached user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(AuthenticatableContract $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
$this->loggedOut = false;
|
||||
|
||||
$this->fireAuthenticatedEvent($user);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current request instance.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request ?: Request::createFromGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current request instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
133
vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php
vendored
Normal file
133
vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
|
||||
class TokenGuard implements Guard
|
||||
{
|
||||
use GuardHelpers;
|
||||
|
||||
/**
|
||||
* The request instance.
|
||||
*
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The name of the query string item from the request containing the API token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $inputKey;
|
||||
|
||||
/**
|
||||
* The name of the token "column" in persistent storage.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $storageKey;
|
||||
|
||||
/**
|
||||
* Create a new authentication guard.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $provider
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserProvider $provider, Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->provider = $provider;
|
||||
$this->inputKey = 'api_token';
|
||||
$this->storageKey = 'api_token';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
$user = null;
|
||||
|
||||
$token = $this->getTokenForRequest();
|
||||
|
||||
if (! empty($token)) {
|
||||
$user = $this->provider->retrieveByCredentials(
|
||||
[$this->storageKey => $token]
|
||||
);
|
||||
}
|
||||
|
||||
return $this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token for the current request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenForRequest()
|
||||
{
|
||||
$token = $this->request->query($this->inputKey);
|
||||
|
||||
if (empty($token)) {
|
||||
$token = $this->request->input($this->inputKey);
|
||||
}
|
||||
|
||||
if (empty($token)) {
|
||||
$token = $this->request->bearerToken();
|
||||
}
|
||||
|
||||
if (empty($token)) {
|
||||
$token = $this->request->getPassword();
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = [])
|
||||
{
|
||||
if (empty($credentials[$this->inputKey])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$credentials = [$this->storageKey => $credentials[$this->inputKey]];
|
||||
|
||||
if ($this->provider->retrieveByCredentials($credentials)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current request instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
43
vendor/laravel/framework/src/Illuminate/Auth/composer.json
vendored
Normal file
43
vendor/laravel/framework/src/Illuminate/Auth/composer.json
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "illuminate/auth",
|
||||
"description": "The Illuminate Auth package.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.6.4",
|
||||
"illuminate/contracts": "5.4.*",
|
||||
"illuminate/http": "5.4.*",
|
||||
"illuminate/queue": "5.4.*",
|
||||
"illuminate/support": "5.4.*",
|
||||
"nesbot/carbon": "~1.20"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Auth\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.4-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/console": "Required to use the auth:clear-resets command (5.4.*).",
|
||||
"illuminate/queue": "Required to fire login / logout events (5.4.*).",
|
||||
"illuminate/session": "Required to use the session based guard (5.4.*)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
Reference in New Issue
Block a user