]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Security/PasswordTooLong.php
Update function / rearrange tab order
[friendica.git] / src / Module / Security / PasswordTooLong.php
index 32008f0486d6e3a2041479eab612f4f6d005d758..eeeae4084ec87257fc0f6e55571be0ac9624cd3b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -24,7 +24,7 @@ namespace Friendica\Module\Security;
 use Friendica\App;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Database\DBA;
 use Friendica\Model\User;
 use Friendica\Module\Response;
@@ -36,12 +36,15 @@ class PasswordTooLong extends \Friendica\BaseModule
 {
        /** @var SystemMessages */
        private $sysmsg;
+       /** @var IHandleUserSessions */
+       private $userSession;
 
-       public function __construct(SystemMessages $sysmsg, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(SystemMessages $sysmsg, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, $server, array $parameters = [])
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               $this->sysmsg = $sysmsg;
+               $this->sysmsg      = $sysmsg;
+               $this->userSession = $userSession;
        }
 
        protected function post(array $request = [])
@@ -55,13 +58,13 @@ class PasswordTooLong extends \Friendica\BaseModule
                        }
 
                        //  check if the old password was supplied correctly before changing it to the new value
-                       User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['password_current']);
+                       User::getIdFromPasswordAuthentication($this->userSession->getLocalUserId(), $request['password_current']);
 
                        if (strlen($request['password_current']) <= 72) {
                                throw new \Exception($this->l10n->t('Password does not need changing.'));
                        }
 
-                       $result = User::updatePassword(Session::getLocalUser(), $newpass);
+                       $result = User::updatePassword($this->userSession->getLocalUserId(), $newpass);
                        if (!DBA::isResult($result)) {
                                throw new \Exception($this->l10n->t('Password update failed. Please try again.'));
                        }
@@ -90,12 +93,11 @@ class PasswordTooLong extends \Friendica\BaseModule
                                'submit' => $this->l10n->t('Update Password'),
                        ],
 
-                       '$baseurl'             => $this->baseUrl->get(true),
                        '$form_security_token' => self::getFormSecurityToken('security/password_too_long'),
                        '$return_url'          => $request['return_url'] ?? '',
 
                        '$password_current' => ['password_current', $this->l10n->t('Current Password:'), '', $this->l10n->t('Your current password to confirm the changes'), 'required', 'autocomplete="off"'],
-                       '$password'         => ['password', $this->l10n->t('New Password:'), '', $this->l10n->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).') . ' ' . $this->l10n->t('Password length is limited to 72 characters.'), 'required', 'autocomplete="off"', User::getPasswordRegExp()],
+                       '$password'         => ['password', $this->l10n->t('New Password:'), '', $this->l10n->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces and accentuated letters.') . ' ' . $this->l10n->t('Password length is limited to 72 characters.'), 'required', 'autocomplete="off"', User::getPasswordRegExp()],
                        '$password_confirm' => ['password_confirm', $this->l10n->t('Confirm:'), '', '', 'required', 'autocomplete="off"'],
                ]);