My first commit of codes
This commit is contained in:
		
							
								
								
									
										116
									
								
								vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										116
									
								
								vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,116 @@ | ||||
| <?php namespace Illuminate\Auth; | ||||
|  | ||||
| use Illuminate\Support\Manager; | ||||
|  | ||||
| class AuthManager extends Manager { | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new driver instance. | ||||
| 	 * | ||||
| 	 * @param  string  $driver | ||||
| 	 * @return mixed | ||||
| 	 */ | ||||
| 	protected function createDriver($driver) | ||||
| 	{ | ||||
| 		$guard = parent::createDriver($driver); | ||||
|  | ||||
| 		// 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. | ||||
| 		$guard->setCookieJar($this->app['cookie']); | ||||
|  | ||||
| 		$guard->setDispatcher($this->app['events']); | ||||
|  | ||||
| 		return $guard->setRequest($this->app->refresh('request', $guard, 'setRequest')); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Call a custom driver creator. | ||||
| 	 * | ||||
| 	 * @param  string  $driver | ||||
| 	 * @return \Illuminate\Auth\Guard | ||||
| 	 */ | ||||
| 	protected function callCustomCreator($driver) | ||||
| 	{ | ||||
| 		$custom = parent::callCustomCreator($driver); | ||||
|  | ||||
| 		if ($custom instanceof Guard) return $custom; | ||||
|  | ||||
| 		return new Guard($custom, $this->app['session.store']); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create an instance of the database driver. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Auth\Guard | ||||
| 	 */ | ||||
| 	public function createDatabaseDriver() | ||||
| 	{ | ||||
| 		$provider = $this->createDatabaseProvider(); | ||||
|  | ||||
| 		return new Guard($provider, $this->app['session.store']); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create an instance of the database user provider. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Auth\DatabaseUserProvider | ||||
| 	 */ | ||||
| 	protected function createDatabaseProvider() | ||||
| 	{ | ||||
| 		$connection = $this->app['db']->connection(); | ||||
|  | ||||
| 		// When using the basic database user provider, we need to inject the table we | ||||
| 		// want to use, since this is not an Eloquent model we will have no way to | ||||
| 		// know without telling the provider, so we'll inject the config value. | ||||
| 		$table = $this->app['config']['auth.table']; | ||||
|  | ||||
| 		return new DatabaseUserProvider($connection, $this->app['hash'], $table); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create an instance of the Eloquent driver. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Auth\Guard | ||||
| 	 */ | ||||
| 	public function createEloquentDriver() | ||||
| 	{ | ||||
| 		$provider = $this->createEloquentProvider(); | ||||
|  | ||||
| 		return new Guard($provider, $this->app['session.store']); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create an instance of the Eloquent user provider. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Auth\EloquentUserProvider | ||||
| 	 */ | ||||
| 	protected function createEloquentProvider() | ||||
| 	{ | ||||
| 		$model = $this->app['config']['auth.model']; | ||||
|  | ||||
| 		return new EloquentUserProvider($this->app['hash'], $model); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the default authentication driver name. | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getDefaultDriver() | ||||
| 	{ | ||||
| 		return $this->app['config']['auth.driver']; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the default authentication driver name. | ||||
| 	 * | ||||
| 	 * @param  string  $name | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function setDefaultDriver($name) | ||||
| 	{ | ||||
| 		$this->app['config']['auth.driver'] = $name; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										73
									
								
								vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| <?php namespace Illuminate\Auth; | ||||
|  | ||||
| use Illuminate\Support\ServiceProvider; | ||||
|  | ||||
| class AuthServiceProvider extends ServiceProvider { | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the service provider. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function register() | ||||
| 	{ | ||||
| 		$this->registerAuthenticator(); | ||||
|  | ||||
| 		$this->registerUserResolver(); | ||||
|  | ||||
| 		$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']->driver(); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Register a resolver for the authenticated user. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function registerUserResolver() | ||||
| 	{ | ||||
| 		$this->app->bind('Illuminate\Contracts\Auth\Authenticatable', function($app) | ||||
| 		{ | ||||
| 			return $app['auth']->user(); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Register a resolver for the authenticated user. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function registerRequestRebindHandler() | ||||
| 	{ | ||||
| 		$this->app->rebinding('request', function($app, $request) | ||||
| 		{ | ||||
| 			$request->setUserResolver(function() use ($app) | ||||
| 			{ | ||||
| 				return $app['auth']->user(); | ||||
| 			}); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										56
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Authenticatable.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Authenticatable.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| <?php namespace Illuminate\Auth; | ||||
|  | ||||
| trait Authenticatable { | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the unique identifier for the user. | ||||
| 	 * | ||||
| 	 * @return mixed | ||||
| 	 */ | ||||
| 	public function getAuthIdentifier() | ||||
| 	{ | ||||
| 		return $this->getKey(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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() | ||||
| 	{ | ||||
| 		return $this->{$this->getRememberTokenName()}; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the token value for the "remember me" session. | ||||
| 	 * | ||||
| 	 * @param  string  $value | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function setRememberToken($value) | ||||
| 	{ | ||||
| 		$this->{$this->getRememberTokenName()} = $value; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the column name for the "remember me" token. | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getRememberTokenName() | ||||
| 	{ | ||||
| 		return 'remember_token'; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										33
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Console/ClearResetsCommand.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Console/ClearResetsCommand.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| <?php namespace Illuminate\Auth\Console; | ||||
|  | ||||
| use Illuminate\Console\Command; | ||||
|  | ||||
| class ClearResetsCommand extends Command { | ||||
|  | ||||
| 	/** | ||||
| 	 * The console command name. | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	protected $name = 'auth:clear-resets'; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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.tokens']->deleteExpired(); | ||||
|  | ||||
| 		$this->info('Expired reset tokens cleared!'); | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										147
									
								
								vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,147 @@ | ||||
| <?php namespace Illuminate\Auth; | ||||
|  | ||||
| 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 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 ($user !== null) | ||||
| 		{ | ||||
| 			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) | ||||
| 	{ | ||||
| 		$plain = $credentials['password']; | ||||
|  | ||||
| 		return $this->hasher->check($plain, $user->getAuthPassword()); | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										125
									
								
								vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,125 @@ | ||||
| <?php namespace Illuminate\Auth; | ||||
|  | ||||
| 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) | ||||
| 	{ | ||||
| 		return $this->createModel()->newQuery()->find($identifier); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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->getKeyName(), $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); | ||||
|  | ||||
| 		$user->save(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 		// 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; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										66
									
								
								vendor/laravel/framework/src/Illuminate/Auth/GeneratorServiceProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								vendor/laravel/framework/src/Illuminate/Auth/GeneratorServiceProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| <?php namespace Illuminate\Auth; | ||||
|  | ||||
| use Illuminate\Support\ServiceProvider; | ||||
| use Illuminate\Auth\Console\ClearResetsCommand; | ||||
|  | ||||
| class GeneratorServiceProvider extends ServiceProvider { | ||||
|  | ||||
| 	/** | ||||
| 	 * Indicates if loading of the provider is deferred. | ||||
| 	 * | ||||
| 	 * @var bool | ||||
| 	 */ | ||||
| 	protected $defer = true; | ||||
|  | ||||
| 	/** | ||||
| 	 * The commands to be registered. | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 */ | ||||
| 	protected $commands = [ | ||||
| 		'ClearResets', | ||||
| 	]; | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the service provider. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function register() | ||||
| 	{ | ||||
| 		foreach ($this->commands as $command) | ||||
| 		{ | ||||
| 			$this->{"register{$command}Command"}(); | ||||
| 		} | ||||
|  | ||||
| 		$this->commands( | ||||
| 			'command.auth.resets.clear' | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the command. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function registerClearResetsCommand() | ||||
| 	{ | ||||
| 		$this->app->singleton('command.auth.resets.clear', function() | ||||
| 		{ | ||||
| 			return new ClearResetsCommand; | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the services provided by the provider. | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public function provides() | ||||
| 	{ | ||||
| 		return [ | ||||
| 			'command.auth.resets.clear', | ||||
| 		]; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										121
									
								
								vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,121 @@ | ||||
| <?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 unique identifier for the user. | ||||
| 	 * | ||||
| 	 * @return mixed | ||||
| 	 */ | ||||
| 	public function getAuthIdentifier() | ||||
| 	{ | ||||
| 		return $this->attributes['id']; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the password for the user. | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getAuthPassword() | ||||
| 	{ | ||||
| 		return $this->attributes['password']; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the token value for the "remember me" session. | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getRememberToken() | ||||
| 	{ | ||||
| 		return $this->attributes[$this->getRememberTokenName()]; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the token value for the "remember me" session. | ||||
| 	 * | ||||
| 	 * @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]); | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										769
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Guard.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										769
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Guard.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,769 @@ | ||||
| <?php namespace Illuminate\Auth; | ||||
|  | ||||
| use RuntimeException; | ||||
| use Illuminate\Contracts\Events\Dispatcher; | ||||
| use Illuminate\Contracts\Auth\UserProvider; | ||||
| use Symfony\Component\HttpFoundation\Request; | ||||
| use Symfony\Component\HttpFoundation\Response; | ||||
| use Illuminate\Contracts\Auth\Guard as GuardContract; | ||||
| use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar; | ||||
| use Illuminate\Contracts\Auth\Authenticatable as UserContract; | ||||
| use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||||
|  | ||||
| class Guard implements GuardContract { | ||||
|  | ||||
| 	/** | ||||
| 	 * The currently authenticated user. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\Contracts\Auth\Authenticatable | ||||
| 	 */ | ||||
| 	protected $user; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 user provider implementation. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\Contracts\Auth\UserProvider | ||||
| 	 */ | ||||
| 	protected $provider; | ||||
|  | ||||
| 	/** | ||||
| 	 * The session used by the guard. | ||||
| 	 * | ||||
| 	 * @var \Symfony\Component\HttpFoundation\Session\SessionInterface | ||||
| 	 */ | ||||
| 	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 $tokenRetrievalAttempted = false; | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new authentication guard. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\UserProvider  $provider | ||||
| 	 * @param  \Symfony\Component\HttpFoundation\Session\SessionInterface  $session | ||||
| 	 * @param  \Symfony\Component\HttpFoundation\Request  $request | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(UserProvider $provider, | ||||
| 								SessionInterface $session, | ||||
| 								Request $request = null) | ||||
| 	{ | ||||
| 		$this->session = $session; | ||||
| 		$this->request = $request; | ||||
| 		$this->provider = $provider; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 currently authenticated user. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Contracts\Auth\Authenticatable|null | ||||
| 	 */ | ||||
| 	public function user() | ||||
| 	{ | ||||
| 		if ($this->loggedOut) return; | ||||
|  | ||||
| 		// If we have already retrieved the user for the current request we can just | ||||
| 		// return it back immediately. We do not want to pull the user data every | ||||
| 		// request into the method because that would tremendously slow an app. | ||||
| 		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)) | ||||
| 		{ | ||||
| 			$user = $this->provider->retrieveById($id); | ||||
| 		} | ||||
|  | ||||
| 		// 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->getRecaller(); | ||||
|  | ||||
| 		if (is_null($user) && ! is_null($recaller)) | ||||
| 		{ | ||||
| 			$user = $this->getUserByRecaller($recaller); | ||||
|  | ||||
| 			if ($user) | ||||
| 			{ | ||||
| 				$this->updateSession($user->getAuthIdentifier()); | ||||
|  | ||||
| 				$this->fireLoginEvent($user, true); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $this->user = $user; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the ID for the currently authenticated user. | ||||
| 	 * | ||||
| 	 * @return int|null | ||||
| 	 */ | ||||
| 	public function id() | ||||
| 	{ | ||||
| 		if ($this->loggedOut) return; | ||||
|  | ||||
| 		$id = $this->session->get($this->getName(), $this->getRecallerId()); | ||||
|  | ||||
| 		if (is_null($id) && $this->user()) | ||||
| 		{ | ||||
| 			$id = $this->user()->getAuthIdentifier(); | ||||
| 		} | ||||
|  | ||||
| 		return $id; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Pull a user from the repository by its recaller ID. | ||||
| 	 * | ||||
| 	 * @param  string  $recaller | ||||
| 	 * @return mixed | ||||
| 	 */ | ||||
| 	protected function getUserByRecaller($recaller) | ||||
| 	{ | ||||
| 		if ($this->validRecaller($recaller) && ! $this->tokenRetrievalAttempted) | ||||
| 		{ | ||||
| 			$this->tokenRetrievalAttempted = true; | ||||
|  | ||||
| 			list($id, $token) = explode('|', $recaller, 2); | ||||
|  | ||||
| 			$this->viaRemember = ! is_null($user = $this->provider->retrieveByToken($id, $token)); | ||||
|  | ||||
| 			return $user; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the decrypted recaller cookie for the request. | ||||
| 	 * | ||||
| 	 * @return string|null | ||||
| 	 */ | ||||
| 	protected function getRecaller() | ||||
| 	{ | ||||
| 		return $this->request->cookies->get($this->getRecallerName()); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the user ID from the recaller cookie. | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	protected function getRecallerId() | ||||
| 	{ | ||||
| 		if ($this->validRecaller($recaller = $this->getRecaller())) | ||||
| 		{ | ||||
| 			return head(explode('|', $recaller)); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Determine if the recaller cookie is in a valid format. | ||||
| 	 * | ||||
| 	 * @param  string  $recaller | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	protected function validRecaller($recaller) | ||||
| 	{ | ||||
| 		if ( ! is_string($recaller) || ! str_contains($recaller, '|')) return false; | ||||
|  | ||||
| 		$segments = explode('|', $recaller); | ||||
|  | ||||
| 		return count($segments) == 2 && trim($segments[0]) !== '' && trim($segments[1]) !== ''; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Log a user into the application without sessions or cookies. | ||||
| 	 * | ||||
| 	 * @param  array  $credentials | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function once(array $credentials = []) | ||||
| 	{ | ||||
| 		if ($this->validate($credentials)) | ||||
| 		{ | ||||
| 			$this->setUser($this->lastAttempted); | ||||
|  | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Validate a user's credentials. | ||||
| 	 * | ||||
| 	 * @param  array  $credentials | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function validate(array $credentials = []) | ||||
| 	{ | ||||
| 		return $this->attempt($credentials, false, false); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Attempt to authenticate using HTTP Basic Auth. | ||||
| 	 * | ||||
| 	 * @param  string  $field | ||||
| 	 * @return \Symfony\Component\HttpFoundation\Response|null | ||||
| 	 */ | ||||
| 	public function basic($field = 'email') | ||||
| 	{ | ||||
| 		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)) return; | ||||
|  | ||||
| 		return $this->getBasicResponse(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Perform a stateless HTTP Basic login attempt. | ||||
| 	 * | ||||
| 	 * @param  string  $field | ||||
| 	 * @return \Symfony\Component\HttpFoundation\Response|null | ||||
| 	 */ | ||||
| 	public function onceBasic($field = 'email') | ||||
| 	{ | ||||
| 		if ( ! $this->once($this->getBasicCredentials($this->getRequest(), $field))) | ||||
| 		{ | ||||
| 			return $this->getBasicResponse(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Attempt to authenticate using basic authentication. | ||||
| 	 * | ||||
| 	 * @param  \Symfony\Component\HttpFoundation\Request  $request | ||||
| 	 * @param  string  $field | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	protected function attemptBasic(Request $request, $field) | ||||
| 	{ | ||||
| 		if ( ! $request->getUser()) return false; | ||||
|  | ||||
| 		return $this->attempt($this->getBasicCredentials($request, $field)); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the credential array for a HTTP Basic request. | ||||
| 	 * | ||||
| 	 * @param  \Symfony\Component\HttpFoundation\Request  $request | ||||
| 	 * @param  string  $field | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	protected function getBasicCredentials(Request $request, $field) | ||||
| 	{ | ||||
| 		return [$field => $request->getUser(), 'password' => $request->getPassword()]; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the response for basic authentication. | ||||
| 	 * | ||||
| 	 * @return \Symfony\Component\HttpFoundation\Response | ||||
| 	 */ | ||||
| 	protected function getBasicResponse() | ||||
| 	{ | ||||
| 		$headers = ['WWW-Authenticate' => 'Basic']; | ||||
|  | ||||
| 		return new Response('Invalid credentials.', 401, $headers); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Attempt to authenticate a user using the given credentials. | ||||
| 	 * | ||||
| 	 * @param  array  $credentials | ||||
| 	 * @param  bool   $remember | ||||
| 	 * @param  bool   $login | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function attempt(array $credentials = [], $remember = false, $login = true) | ||||
| 	{ | ||||
| 		$this->fireAttemptEvent($credentials, $remember, $login); | ||||
|  | ||||
| 		$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)) | ||||
| 		{ | ||||
| 			if ($login) $this->login($user, $remember); | ||||
|  | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		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); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Fire the attempt event with the arguments. | ||||
| 	 * | ||||
| 	 * @param  array  $credentials | ||||
| 	 * @param  bool   $remember | ||||
| 	 * @param  bool   $login | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function fireAttemptEvent(array $credentials, $remember, $login) | ||||
| 	{ | ||||
| 		if ($this->events) | ||||
| 		{ | ||||
| 			$payload = [$credentials, $remember, $login]; | ||||
|  | ||||
| 			$this->events->fire('auth.attempt', $payload); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Register an authentication attempt event listener. | ||||
| 	 * | ||||
| 	 * @param  mixed  $callback | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function attempting($callback) | ||||
| 	{ | ||||
| 		if ($this->events) | ||||
| 		{ | ||||
| 			$this->events->listen('auth.attempt', $callback); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Log a user into the application. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\Authenticatable  $user | ||||
| 	 * @param  bool  $remember | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function login(UserContract $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->createRememberTokenIfDoesntExist($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); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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->fire('auth.login', [$user, $remember]); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Update the session with the given ID. | ||||
| 	 * | ||||
| 	 * @param  string  $id | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function updateSession($id) | ||||
| 	{ | ||||
| 		$this->session->set($this->getName(), $id); | ||||
|  | ||||
| 		$this->session->migrate(true); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Log the given user ID into the application. | ||||
| 	 * | ||||
| 	 * @param  mixed  $id | ||||
| 	 * @param  bool   $remember | ||||
| 	 * @return \Illuminate\Contracts\Auth\Authenticatable | ||||
| 	 */ | ||||
| 	public function loginUsingId($id, $remember = false) | ||||
| 	{ | ||||
| 		$this->session->set($this->getName(), $id); | ||||
|  | ||||
| 		$this->login($user = $this->provider->retrieveById($id), $remember); | ||||
|  | ||||
| 		return $user; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Log the given user ID into the application without sessions or cookies. | ||||
| 	 * | ||||
| 	 * @param  mixed  $id | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function onceUsingId($id) | ||||
| 	{ | ||||
| 		$this->setUser($this->provider->retrieveById($id)); | ||||
|  | ||||
| 		return $this->user instanceof UserContract; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Queue the recaller cookie into the cookie jar. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\Authenticatable  $user | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function queueRecallerCookie(UserContract $user) | ||||
| 	{ | ||||
| 		$value = $user->getAuthIdentifier().'|'.$user->getRememberToken(); | ||||
|  | ||||
| 		$this->getCookieJar()->queue($this->createRecaller($value)); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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->refreshRememberToken($user); | ||||
| 		} | ||||
|  | ||||
| 		if (isset($this->events)) | ||||
| 		{ | ||||
| 			$this->events->fire('auth.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()); | ||||
|  | ||||
| 		$recaller = $this->getRecallerName(); | ||||
|  | ||||
| 		$this->getCookieJar()->queue($this->getCookieJar()->forget($recaller)); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Refresh the remember token for the user. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\Authenticatable  $user | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function refreshRememberToken(UserContract $user) | ||||
| 	{ | ||||
| 		$user->setRememberToken($token = str_random(60)); | ||||
|  | ||||
| 		$this->provider->updateRememberToken($user, $token); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new remember token for the user if one doesn't already exist. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\Authenticatable  $user | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function createRememberTokenIfDoesntExist(UserContract $user) | ||||
| 	{ | ||||
| 		$rememberToken = $user->getRememberToken(); | ||||
|  | ||||
| 		if (empty($rememberToken)) | ||||
| 		{ | ||||
| 			$this->refreshRememberToken($user); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * @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 of the application. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Contracts\Auth\Authenticatable|null | ||||
| 	 */ | ||||
| 	public function getUser() | ||||
| 	{ | ||||
| 		return $this->user; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set the current user of the application. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\Authenticatable  $user | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function setUser(UserContract $user) | ||||
| 	{ | ||||
| 		$this->user = $user; | ||||
|  | ||||
| 		$this->loggedOut = false; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * @return $this | ||||
| 	 */ | ||||
| 	public function setRequest(Request $request) | ||||
| 	{ | ||||
| 		$this->request = $request; | ||||
|  | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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_'.md5(get_class($this)); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the name of the cookie used to store the "recaller". | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getRecallerName() | ||||
| 	{ | ||||
| 		return 'remember_'.md5(get_class($this)); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Determine if the user was authenticated via "remember me" cookie. | ||||
| 	 * | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	public function viaRemember() | ||||
| 	{ | ||||
| 		return $this->viaRemember; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										39
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| <?php namespace Illuminate\Auth\Middleware; | ||||
|  | ||||
| use Closure; | ||||
| use Illuminate\Contracts\Auth\Guard; | ||||
| use Illuminate\Contracts\Routing\Middleware; | ||||
|  | ||||
| class AuthenticateWithBasicAuth implements Middleware { | ||||
|  | ||||
| 	/** | ||||
| 	 * The Guard implementation. | ||||
| 	 * | ||||
| 	 * @var Guard | ||||
| 	 */ | ||||
| 	protected $auth; | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new filter instance. | ||||
| 	 * | ||||
| 	 * @param  Guard  $auth | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(Guard $auth) | ||||
| 	{ | ||||
| 		$this->auth = $auth; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Handle an incoming request. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Http\Request  $request | ||||
| 	 * @param  \Closure  $next | ||||
| 	 * @return mixed | ||||
| 	 */ | ||||
| 	public function handle($request, Closure $next) | ||||
| 	{ | ||||
| 		return $this->auth->basic() ?: $next($request); | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										15
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/CanResetPassword.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/CanResetPassword.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| <?php namespace Illuminate\Auth\Passwords; | ||||
|  | ||||
| trait CanResetPassword { | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the e-mail address where password reset links are sent. | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getEmailForPasswordReset() | ||||
| 	{ | ||||
| 		return $this->email; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										192
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,192 @@ | ||||
| <?php namespace Illuminate\Auth\Passwords; | ||||
|  | ||||
| use Carbon\Carbon; | ||||
| use Illuminate\Database\ConnectionInterface; | ||||
| use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; | ||||
|  | ||||
| class DatabaseTokenRepository implements TokenRepositoryInterface { | ||||
|  | ||||
| 	/** | ||||
| 	 * The database connection instance. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\Database\ConnectionInterface | ||||
| 	 */ | ||||
| 	protected $connection; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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  string  $table | ||||
| 	 * @param  string  $hashKey | ||||
| 	 * @param  int  $expires | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(ConnectionInterface $connection, $table, $hashKey, $expires = 60) | ||||
| 	{ | ||||
| 		$this->table = $table; | ||||
| 		$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($user); | ||||
|  | ||||
| 		$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' => $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) | ||||
| 	{ | ||||
| 		$email = $user->getEmailForPasswordReset(); | ||||
|  | ||||
| 		$token = (array) $this->getTable()->where('email', $email)->where('token', $token)->first(); | ||||
|  | ||||
| 		return $token && ! $this->tokenExpired($token); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Determine if the token has expired. | ||||
| 	 * | ||||
| 	 * @param  array  $token | ||||
| 	 * @return bool | ||||
| 	 */ | ||||
| 	protected function tokenExpired($token) | ||||
| 	{ | ||||
| 		$createdPlusHour = strtotime($token['created_at']) + $this->expires; | ||||
|  | ||||
| 		return $createdPlusHour < $this->getCurrentTime(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the current UNIX timestamp. | ||||
| 	 * | ||||
| 	 * @return int | ||||
| 	 */ | ||||
| 	protected function getCurrentTime() | ||||
| 	{ | ||||
| 		return time(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Delete a token record by token. | ||||
| 	 * | ||||
| 	 * @param  string  $token | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function delete($token) | ||||
| 	{ | ||||
| 		$this->getTable()->where('token', $token)->delete(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Delete expired tokens. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function deleteExpired() | ||||
| 	{ | ||||
| 		$expired = Carbon::now()->subSeconds($this->expires); | ||||
|  | ||||
| 		$this->getTable()->where('created_at', '<', $expired)->delete(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Create a new token for the user. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function createNewToken(CanResetPasswordContract $user) | ||||
| 	{ | ||||
| 		return hash_hmac('sha256', str_random(40), $this->hashKey); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Begin a new database query against the table. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Database\Query\Builder | ||||
| 	 */ | ||||
| 	protected function getTable() | ||||
| 	{ | ||||
| 		return $this->connection->table($this->table); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the database connection instance. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Database\ConnectionInterface | ||||
| 	 */ | ||||
| 	public function getConnection() | ||||
| 	{ | ||||
| 		return $this->connection; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										255
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										255
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,255 @@ | ||||
| <?php namespace Illuminate\Auth\Passwords; | ||||
|  | ||||
| use Closure; | ||||
| use UnexpectedValueException; | ||||
| use Illuminate\Contracts\Auth\UserProvider; | ||||
| use Illuminate\Contracts\Mail\Mailer as MailerContract; | ||||
| 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 mailer instance. | ||||
| 	 * | ||||
| 	 * @var \Illuminate\Contracts\Mail\Mailer | ||||
| 	 */ | ||||
| 	protected $mailer; | ||||
|  | ||||
| 	/** | ||||
| 	 * The view of the password reset link e-mail. | ||||
| 	 * | ||||
| 	 * @var string | ||||
| 	 */ | ||||
| 	protected $emailView; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * @param  \Illuminate\Contracts\Mail\Mailer  $mailer | ||||
| 	 * @param  string  $emailView | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function __construct(TokenRepositoryInterface $tokens, | ||||
|                                 UserProvider $users, | ||||
|                                 MailerContract $mailer, | ||||
|                                 $emailView) | ||||
| 	{ | ||||
| 		$this->users = $users; | ||||
| 		$this->mailer = $mailer; | ||||
| 		$this->tokens = $tokens; | ||||
| 		$this->emailView = $emailView; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Send a password reset link to a user. | ||||
| 	 * | ||||
| 	 * @param  array  $credentials | ||||
| 	 * @param  \Closure|null  $callback | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function sendResetLink(array $credentials, Closure $callback = null) | ||||
| 	{ | ||||
| 		// 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 PasswordBrokerContract::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. | ||||
| 		$token = $this->tokens->create($user); | ||||
|  | ||||
| 		$this->emailResetLink($user, $token, $callback); | ||||
|  | ||||
| 		return PasswordBrokerContract::RESET_LINK_SENT; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Send the password reset link via e-mail. | ||||
| 	 * | ||||
| 	 * @param  \Illuminate\Contracts\Auth\CanResetPassword  $user | ||||
| 	 * @param  string  $token | ||||
| 	 * @param  \Closure|null  $callback | ||||
| 	 * @return int | ||||
| 	 */ | ||||
| 	public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null) | ||||
| 	{ | ||||
| 		// We will use the reminder view that was given to the broker to display the | ||||
| 		// password reminder e-mail. We'll pass a "token" variable into the views | ||||
| 		// so that it may be displayed for an user to click for password reset. | ||||
| 		$view = $this->emailView; | ||||
|  | ||||
| 		return $this->mailer->send($view, compact('token', 'user'), function($m) use ($user, $token, $callback) | ||||
| 		{ | ||||
| 			$m->to($user->getEmailForPasswordReset()); | ||||
|  | ||||
| 			if ( ! is_null($callback)) call_user_func($callback, $m, $user, $token); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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; | ||||
| 		} | ||||
|  | ||||
| 		$pass = $credentials['password']; | ||||
|  | ||||
| 		// Once we have called this callback, we will remove this token row from the | ||||
| 		// table and return the response from this callback so the user gets sent | ||||
| 		// to the destination given by the developers from the callback return. | ||||
| 		call_user_func($callback, $user, $pass); | ||||
|  | ||||
| 		$this->tokens->delete($credentials['token']); | ||||
|  | ||||
| 		return PasswordBrokerContract::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 PasswordBrokerContract::INVALID_USER; | ||||
| 		} | ||||
|  | ||||
| 		if ( ! $this->validateNewPassword($credentials)) | ||||
| 		{ | ||||
| 			return PasswordBrokerContract::INVALID_PASSWORD; | ||||
| 		} | ||||
|  | ||||
| 		if ( ! $this->tokens->exists($user, $credentials['token'])) | ||||
| 		{ | ||||
| 			return PasswordBrokerContract::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) | ||||
| 	{ | ||||
| 		list($password, $confirm) = [ | ||||
| 			$credentials['password'], $credentials['password_confirmation'], | ||||
| 		]; | ||||
|  | ||||
| 		if (isset($this->passwordValidator)) | ||||
| 		{ | ||||
| 			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 = array_except($credentials, ['token']); | ||||
|  | ||||
| 		$user = $this->users->retrieveByCredentials($credentials); | ||||
|  | ||||
| 		if ($user && ! $user instanceof CanResetPasswordContract) | ||||
| 		{ | ||||
| 			throw new UnexpectedValueException("User must implement CanResetPassword interface."); | ||||
| 		} | ||||
|  | ||||
| 		return $user; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the password reset token repository implementation. | ||||
| 	 * | ||||
| 	 * @return \Illuminate\Auth\Passwords\TokenRepositoryInterface | ||||
| 	 */ | ||||
| 	protected function getRepository() | ||||
| 	{ | ||||
| 		return $this->tokens; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										88
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| <?php namespace Illuminate\Auth\Passwords; | ||||
|  | ||||
| use Illuminate\Support\ServiceProvider; | ||||
| use Illuminate\Auth\Passwords\DatabaseTokenRepository as DbRepository; | ||||
|  | ||||
| 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(); | ||||
|  | ||||
| 		$this->registerTokenRepository(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the password broker instance. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function registerPasswordBroker() | ||||
| 	{ | ||||
| 		$this->app->singleton('auth.password', function($app) | ||||
| 		{ | ||||
| 			// The password token repository is responsible for storing the email addresses | ||||
| 			// and password reset tokens. It will be used to verify the tokens are valid | ||||
| 			// for the given e-mail addresses. We will resolve an implementation here. | ||||
| 			$tokens = $app['auth.password.tokens']; | ||||
|  | ||||
| 			$users = $app['auth']->driver()->getProvider(); | ||||
|  | ||||
| 			$view = $app['config']['auth.password.email']; | ||||
|  | ||||
| 			// 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( | ||||
| 				$tokens, $users, $app['mailer'], $view | ||||
| 			); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Register the token repository implementation. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	protected function registerTokenRepository() | ||||
| 	{ | ||||
| 		$this->app->singleton('auth.password.tokens', function($app) | ||||
| 		{ | ||||
| 			$connection = $app['db']->connection(); | ||||
|  | ||||
| 			// The database token repository is an implementation of the token repository | ||||
| 			// interface, and is responsible for the actual storing of auth tokens and | ||||
| 			// their e-mail addresses. We will inject this table and hash key to it. | ||||
| 			$table = $app['config']['auth.password.table']; | ||||
|  | ||||
| 			$key = $app['config']['app.key']; | ||||
|  | ||||
| 			$expire = $app['config']->get('auth.password.expire', 60); | ||||
|  | ||||
| 			return new DbRepository($connection, $table, $key, $expire); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get the services provided by the provider. | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public function provides() | ||||
| 	{ | ||||
| 		return ['auth.password', 'auth.password.tokens']; | ||||
| 	} | ||||
|  | ||||
| } | ||||
							
								
								
									
										39
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| <?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  string  $token | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function delete($token); | ||||
|  | ||||
| 	/** | ||||
| 	 * Delete expired tokens. | ||||
| 	 * | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function deleteExpired(); | ||||
|  | ||||
| } | ||||
							
								
								
									
										38
									
								
								vendor/laravel/framework/src/Illuminate/Auth/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								vendor/laravel/framework/src/Illuminate/Auth/composer.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| { | ||||
|     "name": "illuminate/auth", | ||||
|     "description": "The Illuminate Auth package.", | ||||
|     "license": "MIT", | ||||
|     "homepage": "http://laravel.com", | ||||
|     "support": { | ||||
|         "issues": "https://github.com/laravel/framework/issues", | ||||
|         "source": "https://github.com/laravel/framework" | ||||
|     }, | ||||
|     "authors": [ | ||||
|         { | ||||
|             "name": "Taylor Otwell", | ||||
|             "email": "taylorotwell@gmail.com" | ||||
|         } | ||||
|     ], | ||||
|     "require": { | ||||
|         "php": ">=5.4.0", | ||||
|         "illuminate/contracts": "5.0.*", | ||||
|         "illuminate/http": "5.0.*", | ||||
|         "illuminate/session": "5.0.*", | ||||
|         "illuminate/support": "5.0.*", | ||||
|         "nesbot/carbon": "~1.0" | ||||
|     }, | ||||
|     "autoload": { | ||||
|         "psr-4": { | ||||
|             "Illuminate\\Auth\\": "" | ||||
|         } | ||||
|     }, | ||||
|     "extra": { | ||||
|         "branch-alias": { | ||||
|             "dev-master": "5.0-dev" | ||||
|         } | ||||
|     }, | ||||
|     "suggest": { | ||||
|         "illuminate/console": "Required to use the auth:clear-resets command (5.0.*)." | ||||
|     }, | ||||
|     "minimum-stability": "dev" | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 sujitprasad
					sujitprasad