aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/tokenstorage.php25
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;