From 7064d15e67cd6818e0a03a74fb63d5ca215dd1bd Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 26 Jan 2010 02:40:44 +0000 Subject: [PATCH] Use "Sign in with Twitter" auth pattern and official Twitter button for Twitter-based login. See: http://apiwiki.twitter.com/Sign-in-with-Twitter --- plugins/TwitterBridge/twitter_connect.gif | Bin 2205 -> 0 bytes plugins/TwitterBridge/twitterauthorization.php | 8 +++++--- plugins/TwitterBridge/twitterlogin.php | 11 ++++++----- plugins/TwitterBridge/twitteroauthclient.php | 7 +++++-- 4 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 plugins/TwitterBridge/twitter_connect.gif diff --git a/plugins/TwitterBridge/twitter_connect.gif b/plugins/TwitterBridge/twitter_connect.gif deleted file mode 100644 index e3d8f3ed7b88b41d67b37f8be92f7af532f25816..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2205 zcmV;O2x9j~Nk%w1VZ#6!0OkMyGOg67-0df;(tOI~iqPgGrqG4s`T%UCxby!1|NoiR z>U7=s1AMdT`u<+N-BG#QRK4EB^Zq5M(rv}y7M#u^rO(Ca^Et8E-TMFJ`~FDL^d_m& z)9v;kq|V9r{#DfX;`8}Eve_!A)uZeE@&5l)!QoB5-kj|Hw&L)u@BPyF{urLnAE(ej zver1x^fa&6@cH}_k-@g%?_j{*LbTXLwcN7q{)x}#PPo~V>HH9lzii$4dEogls@Ef@ z(E0rS-uM5??Dvb&=MRp+5RbqptJ5f}(jTPHD6G>UrqCXx&m^ePDXh~Wr_djz&`rMG z1ADR_rq3s=(oVnL0BfTlrO+Rx&mN@CO1Rt;na)PI-NfheLbBN*rqCj!(?ho0A)wG- zz~3pS)Fi0Y8lTW0q|+p;(Lb@)GqKb?wcH||$@%#F&h7Z^_W4e?*)_7;!|(k;&-9nt z@g}IzF09r>x7hLd{3WB(_W1j|?EUrq{-*H$)babK<@2rL@&Et+A^8LV00000EC2ui z0K)(o000O7fKX5jgM|!-g@cESjEIDa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xx1Ja!4G+i))1c)J@`Wylaww79YPYEK+~Gq^rkq?sZMEHg`WEK zr$7y=P=`uXpYHUiNKL9zmx|OX9N`cmT|r30Aeaci!KxAZ$ODx6AW|}{z=B5zt60ZM z*0P%QtY}TETGz_fwz_q!#*C|6b!deS41xl9%_{}ozz4^bMh;%p>kumN*2123u82*n zViRlF#*(!HRyc%SCrjDNQeX&5$gE~J%h}F)_OqH5s})8|+R~c#w5Uz3YNNo~*1Gn! zu#K&3S$l=r+V-}%&8=>Cn_DGB;SgB}u5gD-+~Njz2v-2Da+k~8<~sMe(2cHVXG`7c zS~m(xIK%signin = $this->boolean('signin'); $this->oauth_token = $this->arg('oauth_token'); return true; @@ -160,7 +162,7 @@ class TwitterauthorizationAction extends Action $_SESSION['twitter_request_token'] = $req_tok->key; $_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) { $msg = sprintf('OAuth client cURL error - code: %1s, msg: %2s', diff --git a/plugins/TwitterBridge/twitterlogin.php b/plugins/TwitterBridge/twitterlogin.php index ae468ea15c..ae67b4c154 100644 --- a/plugins/TwitterBridge/twitterlogin.php +++ b/plugins/TwitterBridge/twitterlogin.php @@ -46,7 +46,6 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; * @see SettingsAction */ - class TwitterloginAction extends Action { function handle($args) @@ -67,7 +66,7 @@ class TwitterloginAction extends Action function getInstructions() { - return _('Login with your Twitter Account'); + return _('Login with your Twitter account'); } function showPageNotice() @@ -81,9 +80,11 @@ class TwitterloginAction extends Action function showContent() { - $this->elementStart('a', array('href' => common_local_url('twitterauthorization'))); - $this->element('img', array('src' => common_path('plugins/TwitterBridge/twitter_connect.gif'), - 'alt' => 'Connect my Twitter account')); + $this->elementStart('a', array('href' => common_local_url('twitterauthorization', + null, + 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'); } diff --git a/plugins/TwitterBridge/twitteroauthclient.php b/plugins/TwitterBridge/twitteroauthclient.php index bad2b74ca3..277e7ab409 100644 --- a/plugins/TwitterBridge/twitteroauthclient.php +++ b/plugins/TwitterBridge/twitteroauthclient.php @@ -45,6 +45,7 @@ class TwitterOAuthClient extends OAuthClient { public static $requestTokenURL = 'https://twitter.com/oauth/request_token'; 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'; /** @@ -97,9 +98,11 @@ class TwitterOAuthClient extends OAuthClient * * @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, common_local_url('twitterauthorization')); }