diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2014-10-02 23:25:23 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2014-10-02 23:25:23 +0200 |
| commit | e112e3a40594eb802ccb6549ad4329ae677f9e8d (patch) | |
| tree | a6cecdc9c196ff1ab09c6ae9baaf78728728f922 /lib/tokenstorage.php | |
| parent | 600e904f35d598a64be0139d39b87a59ed5eaa12 (diff) | |
| download | grauphel-e112e3a40594eb802ccb6549ad4329ae677f9e8d.tar.gz grauphel-e112e3a40594eb802ccb6549ad4329ae677f9e8d.zip | |
add DELETE /token/$username/$tokenKey API
Diffstat (limited to 'lib/tokenstorage.php')
| -rw-r--r-- | lib/tokenstorage.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/tokenstorage.php b/lib/tokenstorage.php index cdbce11..92736cc 100644 --- a/lib/tokenstorage.php +++ b/lib/tokenstorage.php @@ -27,6 +27,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 * * @param Token $token Token object to store @@ -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; |
