From a388a5d28c0279b4c2f021258062ca393b969888 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 16 Dec 2020 12:45:30 +0100 Subject: [PATCH] Fix username suggestion in ACP's LoginForm Resolves #3725 --- .../install/files/lib/acp/form/LoginForm.class.php | 11 +++++++---- .../files/lib/system/session/SessionHandler.class.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php index ecf10c9f2c..8aee2cfea3 100755 --- a/wcfsetup/install/files/lib/acp/form/LoginForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LoginForm.class.php @@ -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; + } } } } diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index d779f48ca2..97ab6669ce 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -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; } -- 2.20.1