Fix username suggestion in ACP's LoginForm
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 16 Dec 2020 11:45:30 +0000 (12:45 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2021 11:20:08 +0000 (12:20 +0100)
Resolves #3725

wcfsetup/install/files/lib/acp/form/LoginForm.class.php
wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index ecf10c9f2cb3e07c970cea0697faa1fa401a2ee9..8aee2cfea38adb4d9643e38fc85294597db71ba8 100755 (executable)
@@ -5,13 +5,13 @@ use wcf\data\user\authentication\failure\UserAuthenticationFailureAction;
 use wcf\data\user\User;
 use wcf\data\user\UserProfile;
 use wcf\form\AbstractCaptchaForm;
-use wcf\form\MultifactorAuthenticationForm;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\exception\NamedUserException;
 use wcf\system\exception\UserInputException;
 use wcf\system\request\LinkHandler;
 use wcf\system\request\RequestHandler;
 use wcf\system\request\RouteHandler;
+use wcf\system\session\SessionHandler;
 use wcf\system\user\authentication\EmailUserAuthentication;
 use wcf\system\user\authentication\UserAuthenticationFactory;
 use wcf\system\WCF;
@@ -243,9 +243,12 @@ class LoginForm extends AbstractCaptchaForm {
                
                // get preferred username
                if (empty($_POST)) {
-                       if (isset($_COOKIE[COOKIE_PREFIX.'userID'])) {
-                               $user = new User(intval($_COOKIE[COOKIE_PREFIX.'userID']));
-                               if ($user->userID) $this->username = $user->username;
+                       $cookieData = SessionHandler::getInstance()->getParsedCookieData(false);
+                       if (isset($cookieData['userId'])) {
+                               $user = new User($cookieData['userId']);
+                               if ($user->userID) {
+                                       $this->username = $user->username;
+                               }
                        }
                }
        }
index d779f48ca248c62efffaeeeb8c84bf3d7e5d6b70..97ab6669ceb3b919c7cff6f528f35ef44897a466 100644 (file)
@@ -244,7 +244,7 @@ final class SessionHandler extends SingletonFactory {
         * 
         * @see SessionHandler::parseCookie()
         */
-       private function getParsedCookieData(?bool $isACP = null): ?array {
+       public function getParsedCookieData(?bool $isACP = null): ?array {
                if ($isACP === null) {
                        $isACP = $this->isACP;
                }