the whole shebang

This commit is contained in:
2014-11-25 16:42:40 +01:00
parent 7f74c0613e
commit ab1334c0cf
3686 changed files with 496409 additions and 1 deletions

View File

@@ -0,0 +1,79 @@
<?php namespace Illuminate\Auth;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->registerAuthEvents();
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app['auth'] = $this->app->share(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);
});
}
/**
* Register the events needed for authentication.
*
* @return void
*/
protected function registerAuthEvents()
{
$app = $this->app;
$app->after(function($request, $response) use ($app)
{
// If the authentication service has been used, we'll check for any cookies
// that may be queued by the service. These cookies are all queued until
// they are attached onto Response objects at the end of the requests.
if (isset($app['auth.loaded']))
{
foreach ($app['auth']->getDrivers() as $driver)
{
foreach ($driver->getQueuedCookies() as $cookie)
{
$response->headers->setCookie($cookie);
}
}
}
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('auth');
}
}