Fix bug #3: Inserting notes on PostgreSQL
[grauphel.git] / lib / tokenstorage.php
index 9a173f5c03c26248512848b98e38e2d4515cf97a..f8f0806f95b89d61f9f092c483852af42fb674ce 100644 (file)
@@ -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();