X-Git-Url: https://git.cweiske.de/grauphel.git/blobdiff_plain/db2f09d46ce2f3a46be1b6f6e031492966242025..f7ecfa21088175bc236b1136c1a4b2aa2488f37c:/lib/tokenstorage.php diff --git a/lib/tokenstorage.php b/lib/tokenstorage.php index c40ab33..f8f0806 100644 --- a/lib/tokenstorage.php +++ b/lib/tokenstorage.php @@ -58,7 +58,7 @@ class TokenStorage * * @return OAuth_Token Stored token * - * @throws OAuth_Exception When token does not exist + * @throws OAuthException When token does not exist */ public function loadAndDelete($type, $tokenKey) { @@ -84,7 +84,7 @@ class TokenStorage * * @return OAuth_Token Stored token * - * @throws OAuth_Exception When token does not exist or + * @throws OAuthException When token does not exist or it is invalid */ public function load($type, $tokenKey) { @@ -106,6 +106,30 @@ class TokenStorage return $token; } + /** + * Load multiple tokens + * + * @param string $username User name + * @param string $type Token type: temp, access, verify + * + * @return array Array of Token objects + */ + public function loadForUser($username, $type) + { + $result = \OC_DB::executeAudited( + 'SELECT * FROM `*PREFIX*grauphel_oauth_tokens`' + . ' WHERE `token_user` = ? AND `token_type` = ?', + array($username, $type) + ); + + $tokens = array(); + while ($tokenRow = $result->fetchRow()) { + $tokens[] = $this->fromDb($tokenRow); + } + + return $tokens; + } + protected function fromDb($tokenRow) { $token = new Token();