summaryrefslogtreecommitdiff
path: root/plugins/YammerImport/lib
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-09-27 12:24:10 -0700
committerBrion Vibber <brion@pobox.com>2010-09-28 07:44:25 -0700
commita57d67c91548482c74e07034c7717fa4e1057d3b (patch)
treed60467ffc0993682fb5f46f7434fbca815dafedc /plugins/YammerImport/lib
parent698f5c7a20d5792b629404ce513d2fa2c2bab907 (diff)
Work in progress on fixing auth... looks like the iframe doesn't work though. Sigh.
Diffstat (limited to 'plugins/YammerImport/lib')
-rw-r--r--plugins/YammerImport/lib/yammerauthinitform.php1
-rw-r--r--plugins/YammerImport/lib/yammerauthverifyform.php12
-rw-r--r--plugins/YammerImport/lib/yammerrunner.php21
3 files changed, 25 insertions, 9 deletions
diff --git a/plugins/YammerImport/lib/yammerauthinitform.php b/plugins/YammerImport/lib/yammerauthinitform.php
index 559ec4e7c..5a83a06c2 100644
--- a/plugins/YammerImport/lib/yammerauthinitform.php
+++ b/plugins/YammerImport/lib/yammerauthinitform.php
@@ -56,6 +56,7 @@ class YammerAuthInitForm extends Form
function formData()
{
+ $this->out->hidden('init_auth', '1');
}
/**
diff --git a/plugins/YammerImport/lib/yammerauthverifyform.php b/plugins/YammerImport/lib/yammerauthverifyform.php
index 488b5b8d1..dc9d2ce1b 100644
--- a/plugins/YammerImport/lib/yammerauthverifyform.php
+++ b/plugins/YammerImport/lib/yammerauthverifyform.php
@@ -2,12 +2,12 @@
class YammerAuthVerifyForm extends Form
{
- private $verify_url;
+ private $runner;
- function __construct($out, $auth_url)
+ function __construct($out, YammerRunner $runner)
{
parent::__construct($out);
- $this->verify_url = $auth_url;
+ $this->runner = $runner;
}
/**
@@ -64,6 +64,9 @@ class YammerAuthVerifyForm extends Form
function formData()
{
+ $this->out->input('verify_token', _m('Verification code:'), '', _m("Click through and paste the code it gives you below..."));
+ $this->out->element('iframe', array('id' => 'yammer-oauth',
+ 'src' => $this->runner->getAuthUrl()));
}
/**
@@ -74,9 +77,6 @@ class YammerAuthVerifyForm extends Form
function formActions()
{
- $this->out->input('verify-code', _m('Verification code:'), '', _m("Click through and paste the code it gives you below..."));
$this->out->submit('submit', _m('Verify code'), 'submit', null, _m('Verification code'));
- $this->element('iframe', array('id' => 'yammer-oauth',
- 'src' => $this->auth_url));
}
}
diff --git a/plugins/YammerImport/lib/yammerrunner.php b/plugins/YammerImport/lib/yammerrunner.php
index e0aadff2c..aee6b17e1 100644
--- a/plugins/YammerImport/lib/yammerrunner.php
+++ b/plugins/YammerImport/lib/yammerrunner.php
@@ -123,7 +123,7 @@ class YammerRunner
public function requestAuth()
{
if ($this->state->state != 'init') {
- throw ServerError("Cannot request Yammer auth; already there!");
+ throw new ServerException("Cannot request Yammer auth; already there!");
}
$data = $this->client->requestToken();
@@ -135,7 +135,22 @@ class YammerRunner
$this->state->modified = common_sql_now();
$this->state->update($old);
- return $this->client->authorizeUrl($this->state->oauth_token);
+ return $this->getAuthUrl();
+ }
+
+ /**
+ * When already in requesting-auth state, grab the URL to send the user to
+ * to complete OAuth setup.
+ *
+ * @return string URL
+ */
+ function getAuthUrl()
+ {
+ if ($this->state() == 'requesting-auth') {
+ return $this->client->authorizeUrl($this->state->oauth_token);
+ } else {
+ throw new ServerException('Cannot get Yammer auth URL when not in requesting-auth state!');
+ }
}
/**
@@ -152,7 +167,7 @@ class YammerRunner
public function saveAuthToken($verifier)
{
if ($this->state->state != 'requesting-auth') {
- throw ServerError("Cannot save auth token in Yammer import state {$this->state->state}");
+ throw new ServerException("Cannot save auth token in Yammer import state {$this->state->state}");
}
$data = $this->client->accessToken($verifier);