From: Marcel Werk
Date: Fri, 3 May 2019 18:06:08 +0000 (+0200)
Subject: Improve error messages in "new password" form
X-Git-Tag: 5.2.0_Alpha_1~107
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5ed265f03279d1541fa78a83fad927aa8b7858af;p=GitHub%2FWoltLab%2FWCF.git
Improve error messages in "new password" form
---
diff --git a/wcfsetup/install/files/lib/form/NewPasswordForm.class.php b/wcfsetup/install/files/lib/form/NewPasswordForm.class.php
index 009093e453..27e4e1694b 100644
--- a/wcfsetup/install/files/lib/form/NewPasswordForm.class.php
+++ b/wcfsetup/install/files/lib/form/NewPasswordForm.class.php
@@ -4,6 +4,7 @@ use wcf\data\user\User;
use wcf\data\user\UserAction;
use wcf\data\user\UserEditor;
use wcf\system\exception\IllegalLinkException;
+use wcf\system\exception\NamedUserException;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\request\LinkHandler;
@@ -67,12 +68,16 @@ class NewPasswordForm extends AbstractForm {
$this->user = new User($this->userID);
if (!$this->user->userID) throw new IllegalLinkException();
- if (!$this->user->lostPasswordKey) throw new IllegalLinkException();
+ if (!$this->user->lostPasswordKey) {
+ $this->throwInvalidLinkException();
+ }
if (!\hash_equals($this->user->lostPasswordKey, $this->lostPasswordKey)) {
- throw new IllegalLinkException();
+ $this->throwInvalidLinkException();
}
// expire lost password requests after a day
- if ($this->user->lastLostPasswordRequestTime < TIME_NOW - 86400) throw new IllegalLinkException();
+ if ($this->user->lastLostPasswordRequestTime < TIME_NOW - 86400) {
+ $this->throwInvalidLinkException();
+ }
(new UserEditor($this->user))->update([
'lastLostPasswordRequestTime' => 0,
@@ -158,4 +163,8 @@ class NewPasswordForm extends AbstractForm {
'passwordRulesAttributeValue' => UserRegistrationUtil::getPasswordRulesAttributeValue()
]);
}
+
+ private function throwInvalidLinkException() {
+ throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.newPassword.error.invalidLink'));
+ }
}
diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml
index 007c87eed3..5f2526730d 100644
--- a/wcfsetup/install/lang/de.xml
+++ b/wcfsetup/install/lang/de.xml
@@ -4479,6 +4479,7 @@ dann wird diese Anfrage am {$mailbox->getUser()->lastLostPasswordRequestTime+864
- username}â zu ändern.]]>
- username}â wurde erfolgreich geändert. {if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst dich{else}Sie können sich{/if} nun mit dem neuen Kennwort einloggen.]]>
+ - Kennwort vergessen]]>
diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml
index bde5f809a1..67c1c4278f 100644
--- a/wcfsetup/install/lang/en.xml
+++ b/wcfsetup/install/lang/en.xml
@@ -4478,6 +4478,7 @@ the website {@PAGE_TITLE|language}.
- username}â.]]>
- username}â has been changed successfully. You may now login with your new password.]]>
+ - Lost Password]]>