From: Tim Düsterhus Date: Thu, 16 Jul 2020 12:59:53 +0000 (+0200) Subject: Add zxcvbn to AccountManagementForm X-Git-Tag: 5.3.0_Alpha_1~76^2~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=233d4a52b1f53a63563aa3f3b72440bb11d718ca;p=GitHub%2FWoltLab%2FWCF.git Add zxcvbn to AccountManagementForm --- diff --git a/com.woltlab.wcf/templates/accountManagement.tpl b/com.woltlab.wcf/templates/accountManagement.tpl index 1d90843497..06dd3b3467 100644 --- a/com.woltlab.wcf/templates/accountManagement.tpl +++ b/com.woltlab.wcf/templates/accountManagement.tpl @@ -100,6 +100,22 @@ {event name='changePasswordFields'} + + {/if} diff --git a/wcfsetup/install/files/lib/form/AccountManagementForm.class.php b/wcfsetup/install/files/lib/form/AccountManagementForm.class.php index 286a59badf..88a246a47a 100644 --- a/wcfsetup/install/files/lib/form/AccountManagementForm.class.php +++ b/wcfsetup/install/files/lib/form/AccountManagementForm.class.php @@ -7,10 +7,12 @@ use wcf\system\email\mime\MimePartFacade; use wcf\system\email\mime\RecipientAwareTextMimePart; use wcf\system\email\Email; use wcf\system\email\UserMailbox; +use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; use wcf\system\menu\user\UserMenu; use wcf\system\WCF; use wcf\util\HeaderUtil; +use wcf\util\JSON; use wcf\util\PasswordUtil; use wcf\util\StringUtil; use wcf\util\UserRegistrationUtil; @@ -54,6 +56,11 @@ class AccountManagementForm extends AbstractForm { */ public $newPassword = ''; + /** + * @var mixed[] + */ + public $newPasswordStrengthVerdict = []; + /** * confirmed new password * @var string @@ -151,6 +158,14 @@ class AccountManagementForm extends AbstractForm { if (isset($_POST['email'])) $this->email = $_POST['email']; if (isset($_POST['confirmEmail'])) $this->confirmEmail = $_POST['confirmEmail']; if (isset($_POST['newPassword'])) $this->newPassword = $_POST['newPassword']; + if (isset($_POST['newPassword_passwordStrengthVerdict'])) { + try { + $this->newPasswordStrengthVerdict = JSON::decode($_POST['newPassword_passwordStrengthVerdict']); + } + catch (SystemException $e) { + // ignore + } + } if (isset($_POST['confirmNewPassword'])) $this->confirmNewPassword = $_POST['confirmNewPassword']; if (isset($_POST['username'])) $this->username = StringUtil::trim($_POST['username']); if (isset($_POST['quit'])) $this->quit = intval($_POST['quit']); @@ -215,7 +230,7 @@ class AccountManagementForm extends AbstractForm { throw new UserInputException('confirmNewPassword'); } - if (!UserRegistrationUtil::isSecurePassword($this->newPassword)) { + if (($this->newPasswordStrengthVerdict['score'] ?? 4) < PASSWORD_MIN_SCORE) { throw new UserInputException('newPassword', 'notSecure'); }