From 3274989e5c18c43b0e0474504f4d7f9b7a00f4ed Mon Sep 17 00:00:00 2001 From: kalesh13 Date: Sat, 24 Aug 2019 19:01:32 +0530 Subject: [PATCH] Refactored --- src/ZauthServiceProvider.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) 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'); + } } + }