public function session() { if (Request::segment(2) == 'facebook') { $provider = OAuth2::provider('facebook', array('id' => '494491330565385', 'secret' => '1dd38781d55ed1825724e433ef1ce6e3')); } // if(Request::segment(2) == 'twitter'){ // $provider = OAuth2::provider('twitter', array( // 'id' => '494491330565385', // 'secret' => '1dd38781d55ed1825724e433ef1ce6e3', // )); // } if (Request::segment(2) == 'google') { $provider = OAuth2::provider('google', array('id' => '406188381495-cil9u3fcb7jtu3hq2idinp3s92qvr8f6.apps.googleusercontent.com', 'secret' => 'ZOGyJqHOl5xMfGVQ-wTInqUs')); } if (Request::segment(2) == 'github') { $provider = OAuth2::provider('github', array('id' => '67d050b4c06ad12d95be', 'secret' => '4a03507448e3ffd9904eaa7b6fc7d3d75c373739', 'scope' => 'user:email')); } // if(Request::segment(2) == 'stackexchange'){ // $provider = OAuth2::provider('stackexchange', array( // 'id' => '494491330565385', // 'secret' => '1dd38781d55ed1825724e433ef1ce6e3', // )); // } if (!isset($_GET['code'])) { // By sending no options it'll come back here return $provider->authorize(); } else { // Howzit? try { $params = $provider->access($_GET['code']); $token = new Token_Access(array('access_token' => $params->access_token)); $data = $provider->get_user_info($token); // Here you should use this information to A) look for a user B) help a new user sign up with existing data. // If you store it all in a cookie and redirect to a registration page this is crazy-simple. // return $data; $user_id = $this->checkAndSave($data); if ($user_id == false) { return Redirect::back()->with('error', 'Your email was not public. Please join with another provider.'); //return Response::json(array()); } } catch (OAuth2_Exception $e) { show_error('That didnt work: ' . $e); } } // return Redirect::to('auth/signin')->with('oauth', $data); // return Response::json(array('success' => Lang::get('auth/message.signin.success'))); // return Redirect::to('devs/'.$user_id); // return Redirect::back(); //breaks some times //check for any pending posts and assign then to the signed in user $redirect = All::completePosting(); $redirect = !empty($redirect) ? $redirect : Session::get('loginRedirect', 'account'); return Redirect::to($redirect); // so you can complete creating the post you were creating. temp solutin }