app['auth']->viaRequest('api', function (Request $request) { $token = $request->cookie(Authenticate::CookieName); if ($token) { try { $user = app('pd.auth')->getUserInfo($token); if ($user) { return $user; } } catch (DecryptException $ex) { return null; } } return null; }); } public function register() { $this->app->singleton('pd.auth', function () { $this->app->configure('pdauth'); return new OAuth(config('pdauth')); }); } }