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()