]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix credentialsManager documentation and ensure userId to be used as string 20505/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 15 Apr 2020 17:34:23 +0000 (19:34 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Wed, 15 Apr 2020 17:34:23 +0000 (19:34 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
lib/private/Security/CredentialsManager.php
lib/public/Security/ICredentialsManager.php
tests/lib/Security/CredentialsManagerTest.php

index 770919dacd779ae8db4a2ccbf6ccc0a2d9dc6c2a..d187acdf02b931a0bbee191d4362ebd2eaa1fe06 100644 (file)
@@ -53,7 +53,7 @@ class CredentialsManager implements ICredentialsManager {
        /**
         * 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 mixed $credentials
         */
@@ -61,7 +61,7 @@ class CredentialsManager implements ICredentialsManager {
                $value = $this->crypto->encrypt(json_encode($credentials));
 
                $this->dbConnection->setValues(self::DB_TABLE, [
-                       'user' => $userId,
+                       'user' => (string)$userId,
                        'identifier' => $identifier,
                ], [
                        'credentials' => $value,
@@ -71,7 +71,7 @@ class CredentialsManager implements ICredentialsManager {
        /**
         * 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
         * @return mixed
         */
@@ -79,7 +79,7 @@ class CredentialsManager implements ICredentialsManager {
                $qb = $this->dbConnection->getQueryBuilder();
                $qb->select('credentials')
                        ->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)))
                ;
                $result = $qb->execute()->fetch();
@@ -95,14 +95,14 @@ class CredentialsManager implements ICredentialsManager {
        /**
         * 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
         * @return int rows removed
         */
        public function delete($userId, $identifier) {
                $qb = $this->dbConnection->getQueryBuilder();
                $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)))
                ;
                return $qb->execute();
index b1daad30c9f1621adc9a6a446d160f9faa8179c1..0b34d9a28ca98e3712dcb10da9d153c25350481d 100644 (file)
@@ -33,7 +33,7 @@ interface ICredentialsManager {
        /**
         * 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 mixed $credentials
         * @since 8.2.0
@@ -43,7 +43,7 @@ interface ICredentialsManager {
        /**
         * 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
         * @return mixed
         * @since 8.2.0
@@ -53,7 +53,7 @@ interface ICredentialsManager {
        /**
         * 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
         * @return int rows removed
         * @since 8.2.0
index b5d4116b2930fb002317f424608b853ee7ae2a0d..9c1a0cb9291c0de77d170a10fd6fc7cdadcceb70 100644 (file)
@@ -134,9 +134,9 @@ class CredentialsManagerTest extends \Test\TestCase {
                                'privateCredentials'
                        ],
                        [
-                               null,
-                               'systemCredentials'
-                       ]
+                               '',
+                               'systemCredentials',
+                       ],
                ];
        }
 }