]> git.mxchange.org Git - friendica.git/commitdiff
Fix errors in Security namespace
authorArt4 <art4@wlabs.de>
Sat, 7 Dec 2024 15:10:13 +0000 (15:10 +0000)
committerArt4 <art4@wlabs.de>
Sat, 7 Dec 2024 15:10:13 +0000 (15:10 +0000)
src/Security/OpenWebAuth.php
src/Security/TwoFactor/Repository/TrustedBrowser.php

index 4090fa7378b74a6a6e27749f9ddca7e5db5f3df0..5dd3cf1a27f02f49d8b3ba7c190fe72c9d686280 100644 (file)
@@ -15,6 +15,7 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\OpenWebAuthToken;
+use Friendica\Network\HTTPException\InternalServerErrorException;
 use Friendica\Util\HTTPSignature;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
index 1dfb2e5f9d8782e326772cbb466ab8bb4202a831..b55e1d46eba1a6c7fd2b0c5e4aad87591866ea94 100644 (file)
@@ -11,6 +11,9 @@ use Friendica\Security\TwoFactor;
 use Friendica\Database\Database;
 use Friendica\Security\TwoFactor\Exception\TrustedBrowserNotFoundException;
 use Friendica\Security\TwoFactor\Exception\TrustedBrowserPersistenceException;
+use Friendica\Security\TwoFactor\Collection\TrustedBrowsers as TrustedBrowsersCollection;
+use Friendica\Security\TwoFactor\Factory\TrustedBrowser as TrustedBrowserFactory;
+use Friendica\Security\TwoFactor\Model\TrustedBrowser as TrustedBrowserModel;
 use Psr\Log\LoggerInterface;
 
 class TrustedBrowser
@@ -21,27 +24,27 @@ class TrustedBrowser
        /** @var LoggerInterface  */
        protected $logger;
 
-       /** @var TwoFactor\Factory\TrustedBrowser  */
+       /** @var TrustedBrowserFactory  */
        protected $factory;
 
        protected static $table_name = '2fa_trusted_browser';
 
-       public function __construct(Database $database, LoggerInterface $logger, TwoFactor\Factory\TrustedBrowser $factory = null)
+       public function __construct(Database $database, LoggerInterface $logger, TrustedBrowserFactory $factory = null)
        {
                $this->db      = $database;
                $this->logger  = $logger;
-               $this->factory = $factory ?? new TwoFactor\Factory\TrustedBrowser($logger);
+               $this->factory = $factory ?? new TrustedBrowserFactory($logger);
        }
 
        /**
         * @param string $cookie_hash
         *
-        * @return TwoFactor\Model\TrustedBrowser|null
+        * @return TrustedBrowserModel
         *
         * @throws TrustedBrowserPersistenceException
         * @throws TrustedBrowserNotFoundException
         */
-       public function selectOneByHash(string $cookie_hash): TwoFactor\Model\TrustedBrowser
+       public function selectOneByHash(string $cookie_hash): TrustedBrowserModel
        {
                try {
                        $fields = $this->db->selectFirst(self::$table_name, [], ['cookie_hash' => $cookie_hash]);
@@ -56,13 +59,9 @@ class TrustedBrowser
        }
 
        /**
-        * @param int $uid
-        *
-        * @return TwoFactor\Collection\TrustedBrowsers
-        *
         * @throws TrustedBrowserPersistenceException
         */
-       public function selectAllByUid(int $uid): TwoFactor\Collection\TrustedBrowsers
+       public function selectAllByUid(int $uid): TrustedBrowsersCollection
        {
                try {
                        $rows = $this->db->selectToArray(self::$table_name, [], ['uid' => $uid]);
@@ -71,7 +70,7 @@ class TrustedBrowser
                        foreach ($rows as $fields) {
                                $trustedBrowsers[] = $this->factory->createFromTableRow($fields);
                        }
-                       return new TwoFactor\Collection\TrustedBrowsers($trustedBrowsers);
+                       return new TrustedBrowsersCollection($trustedBrowsers);
 
                } catch (\Exception $exception) {
                        throw new TrustedBrowserPersistenceException(sprintf('selection for uid \'%s\' wasn\'t successful.', $uid));
@@ -79,13 +78,9 @@ class TrustedBrowser
        }
 
        /**
-        * @param TwoFactor\Model\TrustedBrowser $trustedBrowser
-        *
-        * @return bool
-        *
         * @throws TrustedBrowserPersistenceException
         */
-       public function save(TwoFactor\Model\TrustedBrowser $trustedBrowser): bool
+       public function save(TrustedBrowserModel $trustedBrowser): bool
        {
                try {
                        return $this->db->insert(self::$table_name, $trustedBrowser->toArray(), $this->db::INSERT_UPDATE);
@@ -95,13 +90,9 @@ class TrustedBrowser
        }
 
        /**
-        * @param TwoFactor\Model\TrustedBrowser $trustedBrowser
-        *
-        * @return bool
-        *
         * @throws TrustedBrowserPersistenceException
         */
-       public function remove(TwoFactor\Model\TrustedBrowser $trustedBrowser): bool
+       public function remove(TrustedBrowserModel $trustedBrowser): bool
        {
                try {
                        return $this->db->delete(self::$table_name, ['cookie_hash' => $trustedBrowser->cookie_hash]);
@@ -111,11 +102,6 @@ class TrustedBrowser
        }
 
        /**
-        * @param int    $local_user
-        * @param string $cookie_hash
-        *
-        * @return bool
-        *
         * @throws TrustedBrowserPersistenceException
         */
        public function removeForUser(int $local_user, string $cookie_hash): bool
@@ -127,11 +113,6 @@ class TrustedBrowser
                }
        }
 
-       /**
-        * @param int $local_user
-        *
-        * @return bool
-        */
        public function removeAllForUser(int $local_user): bool
        {
                try {