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) {
$userobj = $userobj->find_by_id($user->id);
$authobj_tmp = AuthFactory::create($user->authinstance);
if (method_exists($authobj_tmp, 'change_password')) {
$authobj_tmp->change_password($userobj, $user->password);
$authobj_tmp->change_password($userobj, $user->password, false);
} else {
$userobj->password = '';
$userobj->salt = auth_get_random_salt();
......
......@@ -102,14 +102,17 @@ class AuthInternal extends Auth {
*
* @param object $user The user to change the password for
* @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
*/
public function change_password(User $user, $password) {
public function change_password(User $user, $password, $resetpasswordchange = true) {
$this->must_be_ready();
// Create a salted password and set it for the user
$user->salt = substr(md5(rand(1000000, 9999999)), 2, 8);
$user->password = $this->encrypt_password($password, $user->salt);
$user->passwordchange = 0;
if ($resetpasswordchange) {
$user->passwordchange = 0;
}
$user->commit();
return $user->password;
}
......
Markdown is supported
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