Skip to content

Commit

Permalink
[User Accounts] Fix edge-case that gave a confusing error message (#5956
Browse files Browse the repository at this point in the history
)

When both the password and email fields were empty, an error was displayed saying "Your password cannot match your email address"

While technically accurate, this isn't actually helpful for a user, especially since our checkbox option "Generate new password" requires leaving the password field blank.
  • Loading branch information
johnsaigle authored Jan 29, 2020
1 parent c7cf0ed commit 2b2963a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/user_accounts/php/edit_user.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,14 @@ class Edit_User extends \NDB_Form
//==================================
// Password validation
//==================================
if ($values['Email'] === $values['Password_hash']) {

// Make sure the user is not using their email address as their password.
// Do not show this error if the password is an empty string: in this
// case, that means the email is empty also. It's more appropriate to
// display only the error 'You must enter an email'.
if ($values['Email'] === $values['Password_hash']
&& $values['Password_hash'] !== ''
) {
$errors['Password_Group'] = self::PASSWORD_ERROR_IS_EMAIL;
}
if (!is_null($this->identifier)) {
Expand Down

0 comments on commit 2b2963a

Please # to comment.