X-Git-Url: https://git.cweiske.de/grauphel.git/blobdiff_plain/07c432f5552f975cfe19846bbd499ed5a7d8d7d6..cd37bde4ef0747a11c1221e937027fe17f2894fe:/lib/tokenstorage.php diff --git a/lib/tokenstorage.php b/lib/tokenstorage.php index 9a173f5..f8f0806 100644 --- a/lib/tokenstorage.php +++ b/lib/tokenstorage.php @@ -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();