]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Security/TwoFactor/Trust.php
old boot.php functions replaced in src/module (4)
[friendica.git] / src / Module / Security / TwoFactor / Trust.php
index 1f5fb7418f5b24c1885ed72a487137a981df29e8..3b64056c54c100174620dfff5417872a4b966fb1 100644 (file)
@@ -25,7 +25,9 @@ use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\DI;
 use Friendica\Model\User;
 use Friendica\Model\User\Cookie;
 use Friendica\Module\Response;
@@ -73,7 +75,7 @@ class Trust extends BaseModule
 
        protected function post(array $request = [])
        {
-               if (!local_user() || !$this->session->get('2fa')) {
+               if (!Session::getLocalUser() || !$this->session->get('2fa')) {
                        $this->logger->info('Invalid call', ['request' => $request]);
                        return;
                }
@@ -86,13 +88,13 @@ class Trust extends BaseModule
                        switch ($action) {
                                case 'trust':
                                case 'dont_trust':
-                                       $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(local_user(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
+                                       $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(Session::getLocalUser(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
                                        try {
                                                $this->trustedBrowserRepository->save($trustedBrowser);
 
                                                // The string is sent to the browser to be sent back with each request
                                                if (!$this->cookie->set('2fa_cookie_hash', $trustedBrowser->cookie_hash)) {
-                                                       notice($this->t('Couldn\'t save browser to Cookie.'));
+                                                       DI::sysmsg()->addNotice($this->t('Couldn\'t save browser to Cookie.'));
                                                };
                                        } catch (TrustedBrowserPersistenceException $exception) {
                                                $this->logger->warning('Unexpected error when saving the trusted browser.', ['trustedBrowser' => $trustedBrowser, 'exception' => $exception]);
@@ -114,7 +116,7 @@ class Trust extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user() || !$this->session->get('2fa')) {
+               if (!Session::getLocalUser() || !$this->session->get('2fa')) {
                        $this->baseUrl->redirect();
                }