setPassword now runs validate too
This commit is contained in:
parent
d7a8ee99af
commit
29847f172f
@ -144,22 +144,8 @@ class PasswordsettingsAction extends SettingsAction
|
|||||||
|
|
||||||
if (Event::handle('StartChangePassword', array($this->scoped, $oldpassword, $newpassword))) {
|
if (Event::handle('StartChangePassword', array($this->scoped, $oldpassword, $newpassword))) {
|
||||||
//no handler changed the password, so change the password internally
|
//no handler changed the password, so change the password internally
|
||||||
$user = $this->scoped->getUser();
|
$user->setPassword($newpassword);
|
||||||
$original = clone($user);
|
|
||||||
|
|
||||||
$user->password = common_munge_password($newpassword, $this->scoped);
|
|
||||||
|
|
||||||
$val = $user->validate();
|
|
||||||
if ($val !== true) {
|
|
||||||
// TRANS: Form validation error on page where to change password.
|
|
||||||
throw new ServerException(_('Error saving user; invalid.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$user->update($original)) {
|
|
||||||
// TRANS: Server error displayed on page where to change password when password change
|
|
||||||
// TRANS: could not be made because of a server error.
|
|
||||||
throw new ServerException(_('Cannot save new password.'));
|
|
||||||
}
|
|
||||||
Event::handle('EndChangePassword', array($this->scoped));
|
Event::handle('EndChangePassword', array($this->scoped));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,8 +1017,16 @@ class User extends Managed_DataObject
|
|||||||
$orig = clone($this);
|
$orig = clone($this);
|
||||||
$this->password = common_munge_password($password, $this->getProfile());
|
$this->password = common_munge_password($password, $this->getProfile());
|
||||||
|
|
||||||
|
if ($this->validate() !== true) {
|
||||||
|
// TRANS: Form validation error on page where to change password.
|
||||||
|
throw new ServerException(_('Error saving user; invalid.'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->update($orig)) {
|
if (!$this->update($orig)) {
|
||||||
throw new ServerException("Error updating user '{$nickname}'.");
|
common_log_db_error($this, 'UPDATE', __FILE__);
|
||||||
|
// TRANS: Server error displayed on page where to change password when password change
|
||||||
|
// TRANS: could not be made because of a server error.
|
||||||
|
throw new ServerException(_('Cannot save new password.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user