Use "Sign in with Twitter" auth pattern and official Twitter button for Twitter-based login.
See: http://apiwiki.twitter.com/Sign-in-with-Twitter
This commit is contained in:
parent
1c1abfc284
commit
ce44008d13
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB |
|
@ -53,6 +53,7 @@ class TwitterauthorizationAction extends Action
|
||||||
var $twuid = null;
|
var $twuid = null;
|
||||||
var $tw_fields = null;
|
var $tw_fields = null;
|
||||||
var $access_token = null;
|
var $access_token = null;
|
||||||
|
var $signin = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize class members. Looks for 'oauth_token' parameter.
|
* Initialize class members. Looks for 'oauth_token' parameter.
|
||||||
|
@ -65,6 +66,7 @@ class TwitterauthorizationAction extends Action
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
|
$this->signin = $this->boolean('signin');
|
||||||
$this->oauth_token = $this->arg('oauth_token');
|
$this->oauth_token = $this->arg('oauth_token');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -160,7 +162,7 @@ class TwitterauthorizationAction extends Action
|
||||||
$_SESSION['twitter_request_token'] = $req_tok->key;
|
$_SESSION['twitter_request_token'] = $req_tok->key;
|
||||||
$_SESSION['twitter_request_token_secret'] = $req_tok->secret;
|
$_SESSION['twitter_request_token_secret'] = $req_tok->secret;
|
||||||
|
|
||||||
$auth_link = $client->getAuthorizeLink($req_tok);
|
$auth_link = $client->getAuthorizeLink($req_tok, $this->signin);
|
||||||
|
|
||||||
} catch (OAuthClientException $e) {
|
} catch (OAuthClientException $e) {
|
||||||
$msg = sprintf('OAuth client cURL error - code: %1s, msg: %2s',
|
$msg = sprintf('OAuth client cURL error - code: %1s, msg: %2s',
|
||||||
|
|
|
@ -46,7 +46,6 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
|
||||||
* @see SettingsAction
|
* @see SettingsAction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class TwitterloginAction extends Action
|
class TwitterloginAction extends Action
|
||||||
{
|
{
|
||||||
function handle($args)
|
function handle($args)
|
||||||
|
@ -67,7 +66,7 @@ class TwitterloginAction extends Action
|
||||||
|
|
||||||
function getInstructions()
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('Login with your Twitter Account');
|
return _('Login with your Twitter account');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPageNotice()
|
function showPageNotice()
|
||||||
|
@ -81,9 +80,11 @@ class TwitterloginAction extends Action
|
||||||
|
|
||||||
function showContent()
|
function showContent()
|
||||||
{
|
{
|
||||||
$this->elementStart('a', array('href' => common_local_url('twitterauthorization')));
|
$this->elementStart('a', array('href' => common_local_url('twitterauthorization',
|
||||||
$this->element('img', array('src' => common_path('plugins/TwitterBridge/twitter_connect.gif'),
|
null,
|
||||||
'alt' => 'Connect my Twitter account'));
|
array('signin' => true))));
|
||||||
|
$this->element('img', array('src' => common_path('plugins/TwitterBridge/Sign-in-with-Twitter-lighter.png'),
|
||||||
|
'alt' => 'Sign in with Twitter'));
|
||||||
$this->elementEnd('a');
|
$this->elementEnd('a');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ class TwitterOAuthClient extends OAuthClient
|
||||||
{
|
{
|
||||||
public static $requestTokenURL = 'https://twitter.com/oauth/request_token';
|
public static $requestTokenURL = 'https://twitter.com/oauth/request_token';
|
||||||
public static $authorizeURL = 'https://twitter.com/oauth/authorize';
|
public static $authorizeURL = 'https://twitter.com/oauth/authorize';
|
||||||
|
public static $signinUrl = 'https://twitter.com/oauth/authenticate';
|
||||||
public static $accessTokenURL = 'https://twitter.com/oauth/access_token';
|
public static $accessTokenURL = 'https://twitter.com/oauth/access_token';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,9 +98,11 @@ class TwitterOAuthClient extends OAuthClient
|
||||||
*
|
*
|
||||||
* @return the link
|
* @return the link
|
||||||
*/
|
*/
|
||||||
function getAuthorizeLink($request_token)
|
function getAuthorizeLink($request_token, $signin = false)
|
||||||
{
|
{
|
||||||
return parent::getAuthorizeLink(self::$authorizeURL,
|
$url = ($signin) ? self::$signinUrl : self::$authorizeURL;
|
||||||
|
|
||||||
|
return parent::getAuthorizeLink($url,
|
||||||
$request_token,
|
$request_token,
|
||||||
common_local_url('twitterauthorization'));
|
common_local_url('twitterauthorization'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user