From 69e621a3e882cd060eb4314554aada7167edd897 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 6 Oct 2010 19:20:47 -0700 Subject: - Update ApiOauthAuthorizeAction to 1.0a - Fix enumerable bugs - New page for displaying 1.0a verifier (still needs work) --- actions/apioauthpin.php | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 actions/apioauthpin.php (limited to 'actions/apioauthpin.php') diff --git a/actions/apioauthpin.php b/actions/apioauthpin.php new file mode 100644 index 000000000..5a88b5e59 --- /dev/null +++ b/actions/apioauthpin.php @@ -0,0 +1,69 @@ +. + * + * @category Action + * @package StatusNet + * @author Zach Copley + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR . '/lib/info.php'; + +/** + * Class for displaying an OAuth verifier pin + * + * @category Action + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ApiOauthPinAction extends InfoAction +{ + + function __construct($verifier) + { + $this->verifier = $verifier; + $title = _('Authorization succeeded.'); + parent::__construct($title, $title); + } + + // TODO: Check for logged in state! + + /** + * Display content. + * + * @return nothing + */ + function showContent() + { + // XXX: make this much nicer + $this->element('div', array('class' => 'info'), $this->verifier); + } + +} -- cgit v1.2.3-54-g00ecf From b8f2cc4e6f121f4ffacefb6fe632beb3b25eb126 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 7 Oct 2010 13:51:47 -0700 Subject: Make the verifier pin display a little nicer --- actions/apioauthauthorize.php | 25 ++++++++++++++++--------- actions/apioauthpin.php | 16 +++++++--------- tests/oauth/fetch_temp_creds.php | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) (limited to 'actions/apioauthpin.php') diff --git a/actions/apioauthauthorize.php b/actions/apioauthauthorize.php index 6772052f2..d0b621140 100644 --- a/actions/apioauthauthorize.php +++ b/actions/apioauthauthorize.php @@ -449,21 +449,28 @@ class ApiOauthAuthorizeAction extends Action function showAuthorized() { + $title = sprintf( + _("You have successfully authorized %s."), + $this->app->name + ); - if ($this->reqToken->verified_callback == 'oob') { + $msg = sprintf( + _('Please return to %s and enter the following security code to complete the process.'), + $this->app->name + ); - $pin = new ApiOauthPinAction($this->reqToken->verifier); + if ($this->reqToken->verified_callback == 'oob') { + $pin = new ApiOauthPinAction($title, $msg, $this->reqToken->verifier); $pin->showPage(); - } else { + // NOTE: This should probably never happen; trhow an error instead? + $info = new InfoAction( - _("Authorization succeeded."), - sprintf( - _('The request token %s has been authorized. Please exchange it for an access token using this verifier: %s'), - $this->oauthTokenParam, - $this->reqToken->verifier - ) + $title, + $msg, + $this->oauthTokenParam, + $this->reqToken->verifier ); $info->showPage(); diff --git a/actions/apioauthpin.php b/actions/apioauthpin.php index 5a88b5e59..5e6713a54 100644 --- a/actions/apioauthpin.php +++ b/actions/apioauthpin.php @@ -36,6 +36,8 @@ require_once INSTALLDIR . '/lib/info.php'; /** * Class for displaying an OAuth verifier pin * + * XXX: I'm pretty sure we don't need to check the logged in state here. -- Zach + * * @category Action * @package StatusNet * @author Zach Copley @@ -45,16 +47,13 @@ require_once INSTALLDIR . '/lib/info.php'; class ApiOauthPinAction extends InfoAction { - - function __construct($verifier) + function __construct($title, $message, $verifier) { $this->verifier = $verifier; - $title = _('Authorization succeeded.'); - parent::__construct($title, $title); + $this->title = $title; + parent::__construct($title, $message); } - // TODO: Check for logged in state! - /** * Display content. * @@ -62,8 +61,7 @@ class ApiOauthPinAction extends InfoAction */ function showContent() { - // XXX: make this much nicer - $this->element('div', array('class' => 'info'), $this->verifier); + $this->element('div', array('class' => 'info'), $this->message); + $this->element('div', array('id' => 'oauth_pin'), $this->verifier); } - } diff --git a/tests/oauth/fetch_temp_creds.php b/tests/oauth/fetch_temp_creds.php index 73f502af3..63ca351cd 100755 --- a/tests/oauth/fetch_temp_creds.php +++ b/tests/oauth/fetch_temp_creds.php @@ -56,7 +56,7 @@ try { } catch (Exception $e) { // oh noez print $e->getMessage(); - print "OAuth Request:\n"; + print "\nOAuth Request:\n"; var_dump($req); exit(1); } -- cgit v1.2.3-54-g00ecf