]> git.mxchange.org Git - friendica.git/commitdiff
Add the right exceptions for BaseUrl::redirect and respect them when catching excepti...
authorPhilipp <admin@philipp.info>
Thu, 7 Jul 2022 19:47:39 +0000 (21:47 +0200)
committerPhilipp <admin@philipp.info>
Thu, 7 Jul 2022 19:47:39 +0000 (21:47 +0200)
src/App/BaseURL.php
src/Core/System.php
src/Module/Security/TwoFactor/Trust.php
src/Security/Authentication.php

index f02a5f1fe7768847101e266537369c3eded2ac2b..9152d4bc2f5d3cfefc1c8a6b8e46b7234c38d31b 100644 (file)
@@ -444,6 +444,10 @@ class BaseURL
         * @param string $toUrl The destination URL (Default is empty, which is the default page of the Friendica node)
         * @param bool   $ssl   if true, base URL will try to get called with https:// (works just for relative paths)
         *
+        * @throws HTTPException\FoundException
+        * @throws HTTPException\MovedPermanentlyException
+        * @throws HTTPException\TemporaryRedirectException
+        *
         * @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node
         */
        public function redirect(string $toUrl = '', bool $ssl = false)
index 7601a6f840480caed0bcb597c08600852bc0eb8a..8712b6ca5965f1a5820bd6544957ef6508df7a7e 100644 (file)
@@ -441,6 +441,12 @@ class System
         *
         * @param string $url  The new Location to redirect
         * @param int    $code The redirection code, which is used (Default is 302)
+        *
+        * @throws FoundException
+        * @throws MovedPermanentlyException
+        * @throws TemporaryRedirectException
+        *
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function externalRedirect($url, $code = 302)
        {
index e2f54d152ad218d9cc1f62191aa4596ba53a660e..41772d7b84df514466ee1aaadb6f3a761ac9bfed 100644 (file)
@@ -29,6 +29,9 @@ use Friendica\Core\Session\Capability\IHandleSessions;
 use Friendica\Model\User;
 use Friendica\Model\User\Cookie;
 use Friendica\Module\Response;
+use Friendica\Network\HTTPException\FoundException;
+use Friendica\Network\HTTPException\MovedPermanentlyException;
+use Friendica\Network\HTTPException\TemporaryRedirectException;
 use Friendica\Security\Authentication;
 use Friendica\Util\Profiler;
 use Friendica\Security\TwoFactor;
@@ -97,7 +100,10 @@ class Trust extends BaseModule
 
                        try {
                                $this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
-                       } catch (\Exception $exception) {
+                       } catch (FoundException | TemporaryRedirectException | MovedPermanentlyException $e) {
+                               // exception wanted!
+                               throw $e;
+                       } catch (\Exception $e) {
                                $this->logger->warning('Unexpected error during authentication.', ['user' => $this->app->getLoggedInUserId(), 'exception' => $exception]);
                        }
                }
index a23d0c95579c29359a9615729a573467817e3e67..9f45516f7d30bc4f1374da75e93d03a484f8a51c 100644 (file)
@@ -304,8 +304,13 @@ class Authentication
         * @param bool  $interactive
         * @param bool  $login_refresh
         *
+        * @throws HTTPException\FoundException
+        * @throws HTTPException\MovedPermanentlyException
+        * @throws HTTPException\TemporaryRedirectException
+        * @throws HTTPException\ForbiddenException
+
         * @throws HTTPException\InternalServerErrorException In case of Friendica specific exceptions
-        * @throws Exception In case of general Exceptions (like SQL Grammar exceptions)
+        *
         */
        public function setForUser(App $a, array $user_record, bool $login_initial = false, bool $interactive = false, bool $login_refresh = false)
        {