summaryrefslogtreecommitdiff
path: root/lib/apioauthstore.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-02 07:35:54 +0000
committerZach Copley <zach@status.net>2010-02-02 07:35:54 +0000
commitf1094185e4943ec391abb60757e94bf566e6ecb2 (patch)
tree155f0948dd6d607f0555c8300d7fb5496f891df6 /lib/apioauthstore.php
parent38bebb4c0dbdf7452a55cc46bbb4a80ec55dcabe (diff)
Better token revocation
Diffstat (limited to 'lib/apioauthstore.php')
-rw-r--r--lib/apioauthstore.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/apioauthstore.php b/lib/apioauthstore.php
index 32110d057..1bb11cbca 100644
--- a/lib/apioauthstore.php
+++ b/lib/apioauthstore.php
@@ -159,5 +159,32 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
}
}
+ /**
+ * Revoke specified access token
+ *
+ * Revokes the token specified by $token_key.
+ * Throws exceptions in case of error.
+ *
+ * @param string $token_key the token to be revoked
+ * @param int $type type of token (0 = req, 1 = access)
+ *
+ * @access public
+ *
+ * @return void
+ */
+
+ public function revoke_token($token_key, $type = 0) {
+ $rt = new Token();
+ $rt->tok = $token_key;
+ $rt->type = $type;
+ $rt->state = 0;
+ if (!$rt->find(true)) {
+ throw new Exception('Tried to revoke unknown token');
+ }
+ if (!$rt->delete()) {
+ throw new Exception('Failed to delete revoked token');
+ }
+ }
+
}