1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Removed route system/xup/signup

system/xup/signup is now system/xup/login
This commit is contained in:
Nick Liu 2020-02-26 21:22:45 +01:00
parent 8c072e243b
commit ae6340c233
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637
4 changed files with 15 additions and 125 deletions

View File

@ -34,36 +34,9 @@ class core_system_xup_controller extends eController
public function init()
{
//$back = 'system/xup/test';
$this->backUrl = isset($_GET['back']) ? $_GET['back'] : null;
}
public function actionSignup()
{
$allow = true;
$session = e107::getSession();
if($session->get('HAuthError'))
{
$allow = false;
$session->set('HAuthError', null);
}
if($allow && vartrue($_GET['provider']))
{
$provider = e107::getUserProvider($_GET['provider']);
try
{
$provider->signup($this->backUrl, true, false); // 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;
@ -79,13 +52,14 @@ class core_system_xup_controller extends eController
$provider = e107::getUserProvider($_GET['provider']);
try
{
$provider->login($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL
$provider->login($this->backUrl, true, false); // 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);
}
@ -141,32 +115,12 @@ class core_system_xup_controller extends eController
'provider' => $key,
'back' => $testUrl,
]);
$testSignupUrl = e107::getUrl()->create('system/xup/signup', [
'provider' => $key,
'back' => $testUrl,
]);
echo '<h3>'.$key.'</h3><ul>';
echo '<li><a class="btn btn-default btn-secondary" href="'.$testLoginUrl.'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_09, array('x'=>$key)).'</a></li>';
echo '<li><a class="btn btn-default btn-secondary" href="'.$testSignupUrl.'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></li>';
echo "</ul>";
echo '<h4>'.$key.'</h4>';
echo '<div><a class="btn btn-default btn-secondary" href="'.$testLoginUrl.'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></div>';
}
// print_a($var);
}
echo '<br /><br /><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/test?logout=true').'">'.LAN_XUP_ERRM_12.'</a>';
/*
echo '<h3>Facebook</h3>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>';
echo '<h3>Twitter</h3>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>';
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>';
*/
}
}

View File

@ -135,7 +135,7 @@ class signup_shortcodes extends e_shortcode
else
$button = "<span title='" . $tp->lanVars($lan_plugin_social_xup, $p) . "'>$p</span>";
$callback_url = e107::getUserProvider($p)->generateCallbackUrl($type, e_REQUEST_URL);
$callback_url = e107::getUserProvider($p)->generateCallbackUrl(e_REQUEST_URL);
$text .= " <a title='" . $tp->lanVars($lan_plugin_social_xup, $p) . " ' role='button' class='signup-xup $class' href='$callback_url'>$button</a> ";
}
//TODO different icon options. see: http://zocial.smcllns.com/

View File

@ -1148,16 +1148,10 @@ class e_user_provider
$this->_provider = $provider;
}
private function log($class, $method, $line)
{
// e107::getLog()->add('XUP Debug', ($class.':'.$method.'-'.$line), E_LOG_INFORMATIVE, "XUP_DEBUG");
}
public function setBackUrl($url, $action)
public function setBackUrl($url)
{
# system/xup/login by default
$this->_config['callback'] = $this->generateCallbackUrl($action, $url);
$this->_config['callback'] = $this->generateCallbackUrl($url);
$this->respawnHybridauth();
}
@ -1445,16 +1439,16 @@ class e_user_provider
* XUP Signup Method (falls-back to XUP login when existing user is detected).
* May be used as a simple XUP login link for existing and non-existing users.
*/
public function signup($redirectUrl = true, $loginAfterSuccess = true, $emailAfterSuccess = true)
public function login($redirectUrl = true, $loginAfterSuccess = true, $emailAfterSuccess = true)
{
if (!$this->isSocialLoginEnabled())
{
throw new Exception("Signup failed! This feature is disabled.", 100); // TODO lan
throw new Exception("Login failed! This feature is disabled.", 100); // TODO lan
}
if (!$this->getProvider())
{
throw new Exception("Signup failed! Wrong provider.", 2); // TODO lan
throw new Exception("Login failed! Wrong provider.", 2); // TODO lan
}
if ($redirectUrl)
@ -1480,12 +1474,11 @@ class e_user_provider
// throw new Exception( "Signup failed! User already signed in. ", 1); // TODO lan
}
$this->setBackUrl($redirectUrl, "signup");
$this->setBackUrl($redirectUrl);
$this->adapter = $this->hybridauth->authenticate($this->getProvider());
$profile = $this->adapter->getUserProfile();
$this->log(__CLASS__, __METHOD__, __LINE__);
// returned back, if success...
if ($profile->identifier)
{
@ -1530,8 +1523,6 @@ class e_user_provider
// user_name, user_xup, user_email and user_loginname shouldn't match
$insert = (!empty($userdata['user_email'])) ? "OR user_email='" . $userdata['user_email'] . "' " : "";
$this->log(__CLASS__, __METHOD__, __LINE__);
if ($uid = $sql->retrieve("user", "user_id", "user_xup='" . $sql->escape($this->userId()) . "' " . $insert . " OR user_loginname='{$userdata['user_loginname']}' OR user_name='{$userdata['user_name']}'"))
{
// $this->login($redirectUrl); // auto-login
@ -1626,61 +1617,9 @@ class e_user_provider
return true;
}
$this->log(__CLASS__, __METHOD__, __LINE__);
return false;
}
public function login($redirectUrl = true)
{
if (!$this->isSocialLoginEnabled())
{
throw new Exception("Login failed! This feature is disabled.", 100); // TODO lan
}
if (!$this->getProvider())
{
throw new Exception("Login failed! Wrong provider.", 22); // TODO lan
}
if ($redirectUrl)
{
if (true === $redirectUrl)
{
$redirectUrl = SITEURL;
}
elseif (strpos($redirectUrl, 'http://') !== 0 && strpos($redirectUrl, 'https://') !== 0)
{
$redirectUrl = e107::getUrl()->create($redirectUrl);
}
}
if (e107::getUser()->isUser())
{
if ($redirectUrl)
{
$this->redirectAndForwardMessages($redirectUrl);
}
return true;
}
$this->setBackUrl($redirectUrl, "login");
$this->adapter = $this->hybridauth->authenticate($this->getProvider());
$check = e107::getUser()->setProvider($this)->loginProvider($this->userId());
if ($redirectUrl)
{
$this->redirectAndForwardMessages($redirectUrl);
}
return $check;
}
public function logout()
{
if (
@ -1700,15 +1639,13 @@ class e_user_provider
}
/**
* @param $provider
* @param string $xupAction
* @param string $backUrl
* @return string
*/
public function generateCallbackUrl($xupAction = "login", $backUrl = null)
public function generateCallbackUrl($backUrl = null)
{
return e107::getUrl()->create(
"system/xup/$xupAction",
"system/xup/login",
array(
'provider' => $this->getProvider(),
'back' => $backUrl,

View File

@ -125,7 +125,6 @@ define("LAN_XUP_ERRM_05", "Signup failed! User already exists. Please use 'login
define("LAN_XUP_ERRM_06", "Signup failed! Can't access user email - registration without an email is impossible.");
define("LAN_XUP_ERRM_07", "Social Login Tester");
define("LAN_XUP_ERRM_08", "Please log out of e107 before testing the user login/signup procedure.");
define("LAN_XUP_ERRM_09", "Test login only with [x]");
define("LAN_XUP_ERRM_10", "Test signup/login with [x]");
define("LAN_XUP_ERRM_11", "Logged in:");
define("LAN_XUP_ERRM_12", "Test logout");