From e112e3a40594eb802ccb6549ad4329ae677f9e8d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 2 Oct 2014 23:25:23 +0200 Subject: add DELETE /token/$username/$tokenKey API --- lib/tokenstorage.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/tokenstorage.php b/lib/tokenstorage.php index cdbce11..92736cc 100644 --- a/lib/tokenstorage.php +++ b/lib/tokenstorage.php @@ -26,6 +26,25 @@ namespace OCA\Grauphel\Lib; */ class TokenStorage { + /** + * Delete token + * + * @param string $type Token type: temp, access, verify + * @param string $tokenKey Random token string to load + * + * @return void + * + * @throws OAuthException When token does not exist + */ + public function delete($type, $tokenKey) + { + \OC_DB::executeAudited( + 'DELETE FROM `*PREFIX*grauphel_oauth_tokens`' + . ' WHERE `token_key` = ? AND `token_type` = ?', + array($tokenKey, $type) + ); + } + /** * Store the given token * @@ -66,11 +85,7 @@ class TokenStorage { try { $token = $this->load($type, $tokenKey); - \OC_DB::executeAudited( - 'DELETE FROM `*PREFIX*grauphel_oauth_tokens`' - . ' WHERE `token_key` = ? AND `token_type` = ?', - array($tokenKey, $type) - ); + $this->delete($type, $tokenKey); return $token; } catch (OAuthException $e) { throw $e; -- cgit v1.2.3