backUrl = vartrue($_GET['back']) ? base64_decode($_GET['back']) : true; } public function actionSignup() { $allow = true; $session = e107::getSession(); if($session->get('HAuthError')) { $allow = false; $session->set('HAuthError', null); } if($allow && vartrue($_GET['provider'])) { require_once(e_HANDLER."user_handler.php"); $provider = new e_user_provider($_GET['provider']); try { $provider->signup($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL } catch (Exception $e) { e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true); } } e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl); } public function actionLogin() { $allow = true; $session = e107::getSession(); if($session->get('HAuthError')) { $allow = false; $session->set('HAuthError', null); } if($allow && vartrue($_GET['provider'])) { require_once(e_HANDLER."user_handler.php"); $provider = new e_user_provider($_GET['provider']); try { $provider->login($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL } catch (Exception $e) { e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true); } } e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl); } public function actionTest() { echo 'Login controller

'; if(isset($_GET['lgt'])) { e107::getUser()->logout(); } echo 'Logged in: '.(e107::getUser()->isUser() ? 'true' : 'false'); $provider = e107::getUser()->getProvider(); if($provider) print_a($provider->getUserProfile()); echo '

Test logout'; echo '

Facebook

'; echo '
Test login with Facebook'; echo '
Test signup with Facebook'; echo '

Twitter

'; echo '
Test login with Twitter'; echo '
Test signup with Twitter'; } public function actionEndpoint() { require_once( e_HANDLER."hybridauth/Hybrid/Auth.php" ); require_once( e_HANDLER."hybridauth/Hybrid/Endpoint.php" ); try { Hybrid_Endpoint::process(); } catch (Exception $e) { e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true); $session = e107::getSession(); $session->set('HAuthError', true); } } }