]> git.mxchange.org Git - friendica.git/blobdiff - src/Security/Authentication.php
Merge pull request #10976 from nupplaphil/feat/api_tests
[friendica.git] / src / Security / Authentication.php
index d8d8ba4b424330eea6c00a549d96940a19057d43..0b2fc9f9cf3d15850b7c88cd053b6608fe98cf3b 100644 (file)
@@ -37,7 +37,6 @@ use Friendica\Network\HTTPException;
 use Friendica\Security\TwoFactor\Repository\TrustedBrowser;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Strings;
 use LightOpenID;
 use Friendica\Core\L10n;
 use Psr\Log\LoggerInterface;
@@ -66,6 +65,18 @@ class Authentication
        /** @var IManagePersonalConfigValues */
        private $pConfig;
 
+       /**
+        * Sets the X-Account-Management-Status header
+        *
+        * mainly extracted to make it overridable for tests
+        *
+        * @param array $user_record
+        */
+       protected function setXAccMgmtStatusHeader(array $user_record)
+       {
+               header('X-Account-Management-Status: active; name="' . $user_record['username'] . '"; id="' . $user_record['nickname'] . '"');
+       }
+
        /**
         * Authentication constructor.
         *
@@ -247,7 +258,7 @@ class Authentication
                                ['uid' => User::getIdFromPasswordAuthentication($username, $password)]
                        );
                } catch (Exception $e) {
-                       $this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => Strings::escapeTags($username), 'ip' => $_SERVER['REMOTE_ADDR']]);
+                       $this->logger->warning('authenticate: failed login attempt', ['action' => 'login', 'username' => $username, 'ip' => $_SERVER['REMOTE_ADDR']]);
                        notice($this->l10n->t('Login failed. Please check your credentials.'));
                        $this->baseUrl->redirect();
                }
@@ -315,7 +326,7 @@ class Authentication
                        $this->session->set('cid', $contact['id']);
                }
 
-               header('X-Account-Management-Status: active; name="' . $user_record['username'] . '"; id="' . $user_record['nickname'] . '"');
+               $this->setXAccMgmtStatusHeader($user_record);
 
                if ($login_initial || $login_refresh) {
                        $this->dba->update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $user_record['uid']]);