app['auth']->viaRequest('auth', function (Request $request) { $token = $request->header('Authorization', $request->cookie(Authenticate::CookieName)); if ($token) { try { $user = app('pd.auth')->getUserInfo($token); if ($user) { return $user; } } catch (DecryptException $ex) { return null; } } return null; }); // $config = $this->app['config']['auth']; if (!isset($config['guards']['auth'])) { config(['auth.guards.auth' => ['driver' => 'auth']]); $this->app['auth']->shouldUse('auth'); } } protected function setupConfig() { $source = realpath(__DIR__ . '/../config/pdauth.php'); if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { $this->publishes([$source => config_path('pdauth.php')], 'pdauth'); } elseif ($this->app instanceof LumenApplication) { $this->app->configure('pdauth'); } $this->mergeConfigFrom($source, 'pdauth'); } public function register() { $this->setupConfig(); $this->app->singleton('pd.auth', function () { return new OAuth(config('pdauth')); }); } }