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

Allow for a XUP-only login/signup situation when configured this way.

This commit is contained in:
Cameron 2015-01-23 21:10:30 -08:00
parent 96e94d7a9a
commit e2a72b40a9
5 changed files with 53 additions and 14 deletions

View File

@ -1488,7 +1488,7 @@ $social_logins = array (
"Github" => array (
"enabled" => true,
"keys" => array ( "key" => "", "secret" => "" )
"keys" => array ( "id" => "", "secret" => "" )
),
"Google" => array (
@ -1508,12 +1508,12 @@ $social_logins = array (
"keys" => array ( "id" => "", "secret" => "" )
),
/*
"MySpace" => array (
"enabled" => true,
"keys" => array ( "key" => "", "secret" => "" )
),
*/
"Twitter" => array (
"enabled" => true,

View File

@ -71,7 +71,19 @@ class signup_shortcodes extends e_shortcode
$p = strtolower($p);
if($v['enabled'] == 1)
{
$text .= "<a href='".e107::getUrl()->create('system/xup/login?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'><img class='e-tip' title='Register using your {$p} account' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' /></a>";
// $text .= "<a href='".e107::getUrl()->create('system/xup/login?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'><img class='e-tip' title='Register using your {$p} account' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' /></a>";
$ic = strtolower($p);
if($ic == 'live')
{
$ic = 'windows';
}
// 'signup' Creates a new XUP user if not found, otherwise it logs the person in.
$button = (defset('FONTAWESOME') === 4) ? "<span title='Register using your {$p} account'>".$tp->toGlyph('fa-'.$ic, array('size'=>'3x'))."</span>" : "<img class='e-tip' title='Register using your {$p} account' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' />";
$text .= "&nbsp;<a class='signup-xup' href='".e107::getUrl()->create('system/xup/signup?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'>".$button."</a>&nbsp;";
}
//TODO different icon options. see: http://zocial.smcllns.com/
}
@ -85,7 +97,7 @@ class signup_shortcodes extends e_shortcode
function sc_signup_xup_signup()
{
$pref = e107::getPref('social_login_active');
$tp = e107::getParser();
if(!empty($pref))
{
$text = "";
@ -96,7 +108,16 @@ class signup_shortcodes extends e_shortcode
$p = strtolower($p);
if($v['enabled'] == 1)
{
$text .= "<a href='".e107::getUrl()->create('system/xup/signup?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'><img class='e-tip' title='Register using your {$p} account' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' /></a>";
$ic = strtolower($p);
if($ic == 'live')
{
$ic = 'windows';
}
$button = (defset('FONTAWESOME') === 4) ? "<span title='Register using your {$p} account'>".$tp->toGlyph('fa-'.$ic, array('size'=>'3x'))."</span>" : "<img class='e-tip' title='Register using your {$p} account' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' />";
$text .= "&nbsp;<a class='signup-xup' href='".e107::getUrl()->create('system/xup/signup?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'>".$button."</a>&nbsp;";
}
//TODO different icon options. see: http://zocial.smcllns.com/
}

View File

@ -895,7 +895,7 @@ class e_media
if($type == 'fa4')
{
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before/';
$subject = e107::getFile()->getRemoteContent('http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css');
$subject = e107::getFile()->getRemoteContent('http://netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css');
// print_a($subject);
}
elseif($type == 'fa3')

View File

@ -923,6 +923,10 @@ class e_user_provider
return null;
}
/**
* 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)
{
if(!e107::getPref('social_login_active', false))
@ -949,7 +953,12 @@ class e_user_provider
if(e107::getUser()->isUser())
{
throw new Exception( "Signup failed! User already signed in. ", 1); // TODO lan
if($redirectUrl)
{
e107::getRedirect()->redirect($redirectUrl);
}
return;
// throw new Exception( "Signup failed! User already signed in. ", 1); // TODO lan
}
$this->adapter = $this->hybridauth->authenticate($this->getProvider());
@ -977,15 +986,22 @@ class e_user_provider
$userdata['user_xup'] = $sql->escape($this->userId());
$userdata['user_class'] = ''; // TODO - check (with Steve) initial class for new users feature...
// print_a($userdata);
// user_name, user_xup, user_email and user_loginname shouldn't match
if($sql->db_Count("user", "(*)", "user_xup='".$sql->escape($this->userId())."' OR user_email='{$userdata['user_email']}' OR user_loginname='{$userdata['user_loginname']}' OR user_name='{$userdata['user_name']}'"))
$insert = (!empty($userdata['user_email'])) ? "OR user_email='".$userdata['user_email']."' " : "";
if($sql->count("user", "(*)", "user_xup='".$sql->escape($this->userId())."' ".$insert." OR user_loginname='{$userdata['user_loginname']}' OR user_name='{$userdata['user_name']}'"))
{
throw new Exception( "Signup failed! User already exists. Please use 'login' instead.", 3); // TODO lan
$this->login($redirectUrl); // auto-login
return;
// throw new Exception( "Signup failed! User already exists. Please use 'login' instead.", 3); // TODO lan
}
if(empty($userdata['user_email']))
if(empty($userdata['user_email']) && e107::getPref('disable_emailcheck', 0)==0) // Allow it if set-up that way.
{
throw new Exception( "Signup failed! Can't access user email - registration without an email is impossible.", 4); // TODO lan
throw new Exception( "Signup failed! Can't access user email - registration without an email is impossible.".print_a($userdata,true), 4); // TODO lan
}
// other fields
@ -1015,7 +1031,7 @@ class e_user_provider
{
throw new Exception($user->renderMessages(), 5);
}
### Successful signup!
// FIXME documentation of new signup trigger - usersupprov
@ -1040,6 +1056,8 @@ class e_user_provider
e107::getUser()->loginProvider($this->userId()); // if not proper after-login, return true so user can see login screen
}
if($redirectUrl)
{
e107::getRedirect()->redirect($redirectUrl);

View File

@ -10,7 +10,7 @@ define('VIEWPORT', "width=device-width, initial-scale=1.0");
e107::js("url", "//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js");
e107::css('url', '//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css');
e107::css('url', "//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
e107::css('url', "//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css");
e107::js("footer-inline", "$('.e-tip').tooltip({container: 'body'})"); // activate bootstrap tooltips.