private static function checkLaravelCookie() { $cv = Request::cookie('laravel-remember'); \Debugbar::error("laravel cookie: {$cv}"); $uc = UserCookie::where('cookie', '=', $cv)->get()->first(); if ($uc != null) { $user = User::where('id', '=', $uc->user_id)->get()->first(); Auth::login($user); } }
function oauthReturn() { $code = Input::get('code'); if (!isset($code)) { return View::make('admin-ui::error/500'); } // Log::info(date('H:i:s')." starting request"); $client = App::make('guzzle-client'); try { $response = $client->post('https://sso.communitytogo.com.au/oauth/access_token', ["body" => ["client_secret" => Config::get('punto-cms.c2go-client-secret'), "code" => $code, "client_id" => Config::get('punto-cms.c2go-client-id'), "redirect_uri" => Config::get('punto-cms.c2go-redirect-uri'), "response_type" => "code", "scope" => "view-email", "grant_type" => "authorization_code"]]); } catch (ClientException $e) { // return $e->getResponse(); Log::error($e->getResponse()); return View::make('admin-ui::error/500'); } // Log::info(date('H:i:s')." finished request"); $tok = json_decode($response->getBody())->access_token; try { $response2 = $client->post('https://sso.communitytogo.com.au/user/email', ["body" => ["access_token" => $tok]]); } catch (ClientException $e2) { // return $e2->getResponse(); Log::error($e2->getResponse()); return View::make('admin-ui::error/500'); } $email = $response2->getBody(); if (!isset($email) || User::where('username', '=', $email)->count() === 0) { return View::make('punto-cms::401'); } else { Auth::login(User::where('username', '=', $email)->get()->first()); if (Session::has('return_url')) { return Redirect::to(Session::get('return_url')); } else { return $this->forwardAdmin(); } } }