vendor/contao/installation-bundle/src/InstallToolUser.php line 32

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of Contao.
  5.  *
  6.  * (c) Leo Feyer
  7.  *
  8.  * @license LGPL-3.0-or-later
  9.  */
  10. namespace Contao\InstallationBundle;
  11. use Symfony\Component\HttpFoundation\Session\Session;
  12. class InstallToolUser
  13. {
  14.     private Session $session;
  15.     private int $timeout 300;
  16.     /**
  17.      * @internal
  18.      */
  19.     public function __construct(Session $session)
  20.     {
  21.         $this->session $session;
  22.     }
  23.     public function isAuthenticated(): bool
  24.     {
  25.         if (!$this->session->has('_auth_until') || $this->session->get('_auth_until') < time()) {
  26.             return false;
  27.         }
  28.         // Update the expiration date
  29.         $this->session->set('_auth_until'time() + $this->timeout);
  30.         return true;
  31.     }
  32.     public function setAuthenticated(bool $authenticated): void
  33.     {
  34.         if (true === $authenticated) {
  35.             $this->session->set('_auth_until'time() + $this->timeout);
  36.         } else {
  37.             $this->session->remove('_auth_until');
  38.         }
  39.     }
  40. }