Extend IHandleUserSessions from IHandleSessions and adapt classes

This commit is contained in:
Philipp 2022-10-23 20:41:17 +02:00
parent b72d727a06
commit b5bc1b0844
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
14 changed files with 165 additions and 138 deletions

View file

@ -25,7 +25,7 @@ use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Model\User\Cookie;
@ -51,7 +51,7 @@ class Trust extends BaseModule
protected $app;
/** @var Authentication */
protected $auth;
/** @var IHandleSessions */
/** @var IHandleUserSessions */
protected $session;
/** @var Cookie */
protected $cookie;
@ -60,7 +60,7 @@ class Trust extends BaseModule
/** @var TwoFactor\Repository\TrustedBrowser */
protected $trustedBrowserRepository;
public function __construct(App $app, Authentication $auth, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IHandleSessions $session, Cookie $cookie, TwoFactor\Factory\TrustedBrowser $trustedBrowserFactory, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepositoy, Response $response, array $server, array $parameters = [])
public function __construct(App $app, Authentication $auth, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IHandleUserSessions $session, Cookie $cookie, TwoFactor\Factory\TrustedBrowser $trustedBrowserFactory, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepositoy, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
@ -74,7 +74,7 @@ class Trust extends BaseModule
protected function post(array $request = [])
{
if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
if (!$this->session->getLocalUserId() || !$this->session->get('2fa')) {
$this->logger->info('Invalid call', ['request' => $request]);
return;
}
@ -87,7 +87,7 @@ class Trust extends BaseModule
switch ($action) {
case 'trust':
case 'dont_trust':
$trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(DI::userSession()->getLocalUserId(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
$trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent($this->session->getLocalUserId(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
try {
$this->trustedBrowserRepository->save($trustedBrowser);
@ -115,7 +115,7 @@ class Trust extends BaseModule
protected function content(array $request = []): string
{
if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
if (!$this->session->getLocalUserId() || !$this->session->get('2fa')) {
$this->baseUrl->redirect();
}