Commit 0b479750 authored by Francois Marier's avatar Francois Marier Committed by Gerrit Code Review
Browse files

Merge "Add optional reset of the passwordchange field (bug #775221)"

parents efc32588 e21213ae
...@@ -351,7 +351,7 @@ function uploadcsv_submit(Pieform $form, $values) { ...@@ -351,7 +351,7 @@ function uploadcsv_submit(Pieform $form, $values) {
$userobj = $userobj->find_by_id($user->id); $userobj = $userobj->find_by_id($user->id);
$authobj_tmp = AuthFactory::create($user->authinstance); $authobj_tmp = AuthFactory::create($user->authinstance);
if (method_exists($authobj_tmp, 'change_password')) { if (method_exists($authobj_tmp, 'change_password')) {
$authobj_tmp->change_password($userobj, $user->password); $authobj_tmp->change_password($userobj, $user->password, false);
} else { } else {
$userobj->password = ''; $userobj->password = '';
$userobj->salt = auth_get_random_salt(); $userobj->salt = auth_get_random_salt();
......
...@@ -102,14 +102,17 @@ class AuthInternal extends Auth { ...@@ -102,14 +102,17 @@ class AuthInternal extends Auth {
* *
* @param object $user The user to change the password for * @param object $user The user to change the password for
* @param string $password The password to set for the user * @param string $password The password to set for the user
* @param boolean $resetpasswordchange Whether to reset the passwordchange variable or not
* @return string The new password, or empty if the password could not be set * @return string The new password, or empty if the password could not be set
*/ */
public function change_password(User $user, $password) { public function change_password(User $user, $password, $resetpasswordchange = true) {
$this->must_be_ready(); $this->must_be_ready();
// Create a salted password and set it for the user // Create a salted password and set it for the user
$user->salt = substr(md5(rand(1000000, 9999999)), 2, 8); $user->salt = substr(md5(rand(1000000, 9999999)), 2, 8);
$user->password = $this->encrypt_password($password, $user->salt); $user->password = $this->encrypt_password($password, $user->salt);
$user->passwordchange = 0; if ($resetpasswordchange) {
$user->passwordchange = 0;
}
$user->commit(); $user->commit();
return $user->password; return $user->password;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment