aboutsummaryrefslogtreecommitdiff
path: root/lib/tokenstorage.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2016-03-18 18:05:50 +0100
committerChristian Weiske <cweiske@cweiske.de>2016-03-18 18:05:50 +0100
commit9501f181f621e9023a9cb27cbbc85afb2743eeca (patch)
tree4dd5a46f22b1161c8f891726619c8bc1dcd295bf /lib/tokenstorage.php
parent26fb49247c6046cb7b3ecec28c5889227515204d (diff)
downloadgrauphel-9501f181f621e9023a9cb27cbbc85afb2743eeca.tar.gz
grauphel-9501f181f621e9023a9cb27cbbc85afb2743eeca.zip
#37: Use public database interface; fixes graupel on ownCloud 9
Diffstat (limited to 'lib/tokenstorage.php')
-rw-r--r--lib/tokenstorage.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/tokenstorage.php b/lib/tokenstorage.php
index 92736cc..a184d8e 100644
--- a/lib/tokenstorage.php
+++ b/lib/tokenstorage.php
@@ -14,7 +14,7 @@
namespace OCA\Grauphel\Lib;
/**
- * Token store
+ * OAuth token store
*
* @category Tools
* @package Grauphel
@@ -27,6 +27,16 @@ namespace OCA\Grauphel\Lib;
class TokenStorage
{
/**
+ * @var \OCP\IDBConnection
+ */
+ protected $db;
+
+ public function __construct($urlGen)
+ {
+ $this->db = \OC::$server->getDatabaseConnection();
+ }
+
+ /**
* Delete token
*
* @param string $type Token type: temp, access, verify
@@ -38,7 +48,7 @@ class TokenStorage
*/
public function delete($type, $tokenKey)
{
- \OC_DB::executeAudited(
+ $this->db->executeQuery(
'DELETE FROM `*PREFIX*grauphel_oauth_tokens`'
. ' WHERE `token_key` = ? AND `token_type` = ?',
array($tokenKey, $type)
@@ -54,7 +64,7 @@ class TokenStorage
*/
public function store(Token $token)
{
- \OC_DB::executeAudited(
+ $this->db->executeQuery(
'INSERT INTO `*PREFIX*grauphel_oauth_tokens`'
. '(`token_user`, `token_type`, `token_key`, `token_secret`, `token_verifier`, `token_callback`, `token_client`, `token_lastuse`)'
. ' VALUES(?, ?, ?, ?, ?, ?, ?, ?)',
@@ -105,11 +115,11 @@ class TokenStorage
*/
public function load($type, $tokenKey)
{
- $tokenRow = \OC_DB::executeAudited(
+ $tokenRow = $this->db->executeQuery(
'SELECT * FROM `*PREFIX*grauphel_oauth_tokens`'
. ' WHERE `token_key` = ? AND `token_type` = ?',
array($tokenKey, $type)
- )->fetchRow();
+ )->fetch();
if ($tokenRow === false) {
throw new OAuthException(
@@ -136,14 +146,14 @@ class TokenStorage
*/
public function loadForUser($username, $type)
{
- $result = \OC_DB::executeAudited(
+ $result = $this->db->executeQuery(
'SELECT * FROM `*PREFIX*grauphel_oauth_tokens`'
. ' WHERE `token_user` = ? AND `token_type` = ?',
array($username, $type)
);
$tokens = array();
- while ($tokenRow = $result->fetchRow()) {
+ while ($tokenRow = $result->fetch()) {
$tokens[] = $this->fromDb($tokenRow);
}
@@ -159,7 +169,7 @@ class TokenStorage
*/
public function updateLastUse($tokenKey)
{
- \OC_DB::executeAudited(
+ $this->db->executeQuery(
'UPDATE `*PREFIX*grauphel_oauth_tokens`'
. ' SET `token_lastuse` = ? WHERE `token_key` = ?',
array(