X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fapioauthstore.php;h=1bb11cbca5cdcbb5230f18efe4eab8f15448b1dc;hb=b42e044f6e5111fe6cb7d4a7b7431cd9b9b67ccb;hp=32110d057572923ff183868a6b89cb057815f65b;hpb=5e1a9ad04d4e10ee44881a26ea72c9a80f748188;p=quix0rs-gnu-social.git diff --git a/lib/apioauthstore.php b/lib/apioauthstore.php index 32110d0575..1bb11cbca5 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'); + } + } + }