diff --git a/src/ZauthServiceProvider.php b/src/ZauthServiceProvider.php index 5869647..db7832a 100644 --- a/src/ZauthServiceProvider.php +++ b/src/ZauthServiceProvider.php @@ -11,10 +11,15 @@ class ZauthServiceProvider extends ServiceProvider { public function boot() { - if ($this->app->runningInConsole()) { - $this->commands(ZclientCommand::class); - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); - } + // Register the authentication guard + Auth::extend('zauth', function ($app, $name, array $config) { + return new Zguard( + Auth::createUserProvider($config['provider']), + $app['request'], + $app['cookie'] + ); + }); + // Register the package middlewares. $router = $this->app['router']; @@ -26,13 +31,11 @@ public function boot() $router->aliasMiddleware('adminOrClient', \Zauth\Http\Middleware\AdminOrClient::class); } - // Register the authentication guard - Auth::extend('zauth', function ($app, $name, array $config) { - return new Zguard( - Auth::createUserProvider($config['provider']), - $app['request'], - $app['cookie'] - ); - }); + // Register package commands and database migrations + if ($this->app->runningInConsole()) { + $this->commands(ZclientCommand::class); + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); + } } + }