From 5172b975b5223a929700e2bd15443f408c52589f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Wed, 2 May 2018 10:55:13 +0800 Subject: [PATCH] change guard --- src/PdAuth/Middleware/Authenticate.php | 2 +- src/PdAuth/PdAuthServiceProvider.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/PdAuth/Middleware/Authenticate.php b/src/PdAuth/Middleware/Authenticate.php index 9bbfa80..6acd445 100644 --- a/src/PdAuth/Middleware/Authenticate.php +++ b/src/PdAuth/Middleware/Authenticate.php @@ -37,7 +37,7 @@ class Authenticate * @param string|null $guard * @return mixed */ - public function handle($request, Closure $next, $guard = null) + public function handle($request, Closure $next, $guard = 'auth') { //oauth 回调 $code = $request->input('pd_code'); diff --git a/src/PdAuth/PdAuthServiceProvider.php b/src/PdAuth/PdAuthServiceProvider.php index 248d8bf..26542a1 100644 --- a/src/PdAuth/PdAuthServiceProvider.php +++ b/src/PdAuth/PdAuthServiceProvider.php @@ -22,7 +22,7 @@ class PdAuthServiceProvider extends ServiceProvider // should return either a User instance or null. You're free to obtain // the User instance via an API token or any other method necessary. - $this->app['auth']->viaRequest('api', function (Request $request) { + $this->app['auth']->viaRequest('auth', function (Request $request) { $token = $request->cookie(Authenticate::CookieName); @@ -38,6 +38,13 @@ class PdAuthServiceProvider extends ServiceProvider } return null; }); +// + $config = $this->app['config']['auth']; + + if (!isset($config['guards']['auth'])) { + config(['auth.guards.auth' => ['driver' => 'auth']]); + config(['auth.defaults.guard' => 'auth']); + } } protected function setupConfig()