X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fapioauthstore.php;h=eca93866f002bc982c53aea354d88f2847ebd917;hb=621233e1ad6956cfb543042a1493a04b243e92ca;hp=32110d057572923ff183868a6b89cb057815f65b;hpb=1f6bbc189012cb3a1d61be92bbc1d4ec6156afac;p=quix0rs-gnu-social.git diff --git a/lib/apioauthstore.php b/lib/apioauthstore.php index 32110d0575..eca93866f0 100644 --- a/lib/apioauthstore.php +++ b/lib/apioauthstore.php @@ -23,7 +23,6 @@ require_once INSTALLDIR . '/lib/oauthstore.php'; class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore { - function lookup_consumer($consumer_key) { $con = Consumer::staticGet('consumer_key', $consumer_key); @@ -39,7 +38,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore function getAppByRequestToken($token_key) { // Look up the full req tokenx - $req_token = $this->lookup_token(null, 'request', $token_key); @@ -50,7 +48,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore } // Look up the full Token - $token = new Token(); $token->tok = $req_token->key; $result = $token->find(true); @@ -150,14 +147,40 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore } // Okay, good - return new OAuthToken($at->tok, $at->secret); } - } else { return null; } } -} + /** + * 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)) { + // TRANS: Exception thrown when an attempt is made to revoke an unknown token. + throw new Exception(_('Tried to revoke unknown token.')); + } + if (!$rt->delete()) { + // TRANS: Exception thrown when an attempt is made to remove a revoked token. + throw new Exception(_('Failed to delete revoked token.')); + } + } +}