summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/oauthstore.php14
-rw-r--r--lib/omb.php12
-rw-r--r--lib/util.php6
3 files changed, 28 insertions, 4 deletions
diff --git a/lib/oauthstore.php b/lib/oauthstore.php
index 4ad123455..688c7477a 100644
--- a/lib/oauthstore.php
+++ b/lib/oauthstore.php
@@ -106,9 +106,21 @@ class LaconicaOAuthDataStore extends OAuthDataStore {
$rt->state = 2; # used
if (!$rt->update($orig_rt)) {
return NULL;
+ }
+ # Update subscription
+ # XXX: mixing levels here
+ $sub = Subscription::staticGet('token', $rt->tok);
+ if (!$sub) {
+ return NULL;
+ }
+ $orig_sub = clone($sub);
+ $sub->token = $at->tok;
+ $sub->secret = $at->secret;
+ if (!$sub->update($orig_sub)) {
+ return NULL;
} else {
return new OAuthToken($at->tok, $at->secret);
- }
+ }
}
} else {
return NULL;
diff --git a/lib/omb.php b/lib/omb.php
index 19ac66ee2..7c7a21cc8 100644
--- a/lib/omb.php
+++ b/lib/omb.php
@@ -42,7 +42,7 @@ define('OAUTH_POST_BODY', OAUTH_NAMESPACE.'parameters/post-body');
define('OAUTH_HMAC_SHA1', OAUTH_NAMESPACE.'signature/HMAC-SHA1');
function omb_oauth_consumer() {
- static $con = null;
+ static $con = NULL;
if (!$con) {
$con = new OAuthConsumer(common_root_url(), '');
}
@@ -52,12 +52,20 @@ function omb_oauth_consumer() {
function omb_oauth_server() {
static $server = null;
if (!$server) {
- $server = new OAuthServer(new LaconicaOAuthDataStore());
+ $server = new OAuthServer(omb_oauth_datastore());
$server->add_signature_method(omb_hmac_sha1());
}
return $server;
}
+function omb_oauth_datastore() {
+ static $store = NULL;
+ if (!$store) {
+ $store = new LaconicaOAuthDataStore();
+ }
+ return $store;
+}
+
function omb_hmac_sha1() {
static $hmac_method = NULL;
if (!$hmac_method) {
diff --git a/lib/util.php b/lib/util.php
index de15d13de..a222f85f6 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -588,4 +588,8 @@ function common_log($priority, $msg) {
function common_debug($msg) {
common_log(LOG_DEBUG, $msg);
-} \ No newline at end of file
+}
+
+function common_valid_http_url($url) {
+ return Validate::uri($url, array('allowed_schemes' => array('http', 'https')));
+}