]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Security/Logout.php
Remove the activity
[friendica.git] / src / Module / Security / Logout.php
index f9c702d51b22af2543ff308aa934b59a766dd582..528dd295e7592eaa6834de89149cbd5b0114d103 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -26,12 +26,12 @@ use Friendica\BaseModule;
 use Friendica\Core\Cache\Capability\ICanCache;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
-use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Core\System;
+use Friendica\DI;
 use Friendica\Model\Profile;
 use Friendica\Model\User\Cookie;
 use Friendica\Module\Response;
-use Friendica\Security\TwoFactor;
 use Friendica\Util\Profiler;
 use Psr\Log\LoggerInterface;
 
@@ -44,19 +44,16 @@ class Logout extends BaseModule
        protected $cache;
        /** @var Cookie */
        protected $cookie;
-       /** @var IHandleSessions */
+       /** @var IHandleUserSessions */
        protected $session;
-       /** @var TwoFactor\Repository\TrustedBrowser */
-       protected $trustedBrowserRepo;
 
-       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, ICanCache $cache, Cookie $cookie, IHandleSessions $session, array $server, array $parameters = [])
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, ICanCache $cache, Cookie $cookie, IHandleUserSessions $session, array $server, array $parameters = [])
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               $this->cache              = $cache;
-               $this->cookie             = $cookie;
-               $this->session            = $session;
-               $this->trustedBrowserRepo = $trustedBrowserRepo;
+               $this->cache   = $cache;
+               $this->cookie  = $cookie;
+               $this->session = $session;
        }
 
 
@@ -66,16 +63,16 @@ class Logout extends BaseModule
        protected function rawContent(array $request = [])
        {
                $visitor_home = null;
-               if (remote_user()) {
+               if ($this->session->getRemoteUserId()) {
                        $visitor_home = Profile::getMyURL();
                        $this->cache->delete('zrlInit:' . $visitor_home);
                }
 
                Hook::callAll("logging_out");
 
-               // Remove this trusted browser as it won't be able to be used ever again after the cookie is cleared
-               if ($this->cookie->get('trusted')) {
-                       $this->trustedBrowserRepo->removeForUser(local_user(), $this->cookie->get('trusted'));
+               // If this is a trusted browser, redirect to the 2fa signout page
+               if ($this->cookie->get('2fa_cookie_hash')) {
+                       $this->baseUrl->redirect('2fa/signout');
                }
 
                $this->cookie->clear();
@@ -84,7 +81,7 @@ class Logout extends BaseModule
                if ($visitor_home) {
                        System::externalRedirect($visitor_home);
                } else {
-                       info($this->t('Logged out.'));
+                       DI::sysmsg()->addInfo($this->t('Logged out.'));
                        $this->baseUrl->redirect();
                }
        }