Skip to content
Snippets Groups Projects
Unverified Commit 5437844b authored by Arthur Schiwon's avatar Arthur Schiwon
Browse files

fix credentialsManager documentation and ensure userId to be used as string

parent f6cb4520
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,7 @@ class CredentialsManager implements ICredentialsManager { ...@@ -53,7 +53,7 @@ class CredentialsManager implements ICredentialsManager {
/** /**
* Store a set of credentials * Store a set of credentials
* *
* @param string|null $userId Null for system-wide credentials * @param string $userId empty string for system-wide credentials
* @param string $identifier * @param string $identifier
* @param mixed $credentials * @param mixed $credentials
*/ */
...@@ -61,7 +61,7 @@ class CredentialsManager implements ICredentialsManager { ...@@ -61,7 +61,7 @@ class CredentialsManager implements ICredentialsManager {
$value = $this->crypto->encrypt(json_encode($credentials)); $value = $this->crypto->encrypt(json_encode($credentials));
$this->dbConnection->setValues(self::DB_TABLE, [ $this->dbConnection->setValues(self::DB_TABLE, [
'user' => $userId, 'user' => (string)$userId,
'identifier' => $identifier, 'identifier' => $identifier,
], [ ], [
'credentials' => $value, 'credentials' => $value,
...@@ -71,7 +71,7 @@ class CredentialsManager implements ICredentialsManager { ...@@ -71,7 +71,7 @@ class CredentialsManager implements ICredentialsManager {
/** /**
* Retrieve a set of credentials * Retrieve a set of credentials
* *
* @param string|null $userId Null for system-wide credentials * @param string $userId empty string for system-wide credentials
* @param string $identifier * @param string $identifier
* @return mixed * @return mixed
*/ */
...@@ -79,7 +79,7 @@ class CredentialsManager implements ICredentialsManager { ...@@ -79,7 +79,7 @@ class CredentialsManager implements ICredentialsManager {
$qb = $this->dbConnection->getQueryBuilder(); $qb = $this->dbConnection->getQueryBuilder();
$qb->select('credentials') $qb->select('credentials')
->from(self::DB_TABLE) ->from(self::DB_TABLE)
->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) ->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
; ;
$result = $qb->execute()->fetch(); $result = $qb->execute()->fetch();
...@@ -95,14 +95,14 @@ class CredentialsManager implements ICredentialsManager { ...@@ -95,14 +95,14 @@ class CredentialsManager implements ICredentialsManager {
/** /**
* Delete a set of credentials * Delete a set of credentials
* *
* @param string|null $userId Null for system-wide credentials * @param string $userId empty string for system-wide credentials
* @param string $identifier * @param string $identifier
* @return int rows removed * @return int rows removed
*/ */
public function delete($userId, $identifier) { public function delete($userId, $identifier) {
$qb = $this->dbConnection->getQueryBuilder(); $qb = $this->dbConnection->getQueryBuilder();
$qb->delete(self::DB_TABLE) $qb->delete(self::DB_TABLE)
->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) ->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
; ;
return $qb->execute(); return $qb->execute();
......
...@@ -33,7 +33,7 @@ interface ICredentialsManager { ...@@ -33,7 +33,7 @@ interface ICredentialsManager {
/** /**
* Store a set of credentials * Store a set of credentials
* *
* @param string|null $userId Null for system-wide credentials * @param string $userId empty string for system-wide credentials
* @param string $identifier * @param string $identifier
* @param mixed $credentials * @param mixed $credentials
* @since 8.2.0 * @since 8.2.0
...@@ -43,7 +43,7 @@ interface ICredentialsManager { ...@@ -43,7 +43,7 @@ interface ICredentialsManager {
/** /**
* Retrieve a set of credentials * Retrieve a set of credentials
* *
* @param string|null $userId Null for system-wide credentials * @param string $userId empty string for system-wide credentials
* @param string $identifier * @param string $identifier
* @return mixed * @return mixed
* @since 8.2.0 * @since 8.2.0
...@@ -53,7 +53,7 @@ interface ICredentialsManager { ...@@ -53,7 +53,7 @@ interface ICredentialsManager {
/** /**
* Delete a set of credentials * Delete a set of credentials
* *
* @param string|null $userId Null for system-wide credentials * @param string $userId empty string for system-wide credentials
* @param string $identifier * @param string $identifier
* @return int rows removed * @return int rows removed
* @since 8.2.0 * @since 8.2.0
......
...@@ -134,9 +134,9 @@ class CredentialsManagerTest extends \Test\TestCase { ...@@ -134,9 +134,9 @@ class CredentialsManagerTest extends \Test\TestCase {
'privateCredentials' 'privateCredentials'
], ],
[ [
null, '',
'systemCredentials' 'systemCredentials',
] ],
]; ];
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment