Commit a0d0bb23 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Move reset_password into create_user function (bug #799594)



Change-Id: I9783aab92858cf1827609497d026aebd30cad36e
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent f5d0fb6c
......@@ -350,8 +350,6 @@ function adduser_submit(Pieform $form, $values) {
}
}
reset_password($user);
$SESSION->add_ok_msg(get_string('newusercreated', 'admin'));
redirect('/admin/users/edit.php?id=' . $user->id);
}
......
......@@ -367,10 +367,6 @@ function finish_import() {
}
}
foreach ($ADDEDUSERS as $user) {
reset_password($user);
}
if (!empty($FAILEDUSERS)) {
$message = get_string('importfailedfornusers', 'admin', count($FAILEDUSERS), $totalusers) . "\n<ul>\n";
foreach ($FAILEDUSERS as $username => $error) {
......
......@@ -498,7 +498,6 @@ function uploadcsv_submit(Pieform $form, $values) {
$user->passwordchange = (int)$values['forcepasswordchange'];
$user->id = create_user($user, $profilefields, $institution, $authrecord, $remoteuser);
reset_password($user, false);
$addedusers[] = $user;
log_debug('added user ' . $user->username);
......
......@@ -1627,7 +1627,7 @@ function reset_password($user, $resetpasswordchange=true) {
$userobj = new User();
$userobj->find_by_id($user->id);
$authobj = AuthFactory::create($user->authinstance);
if (method_exists($authobj, 'change_password')) {
if (isset($user->password) && $user->password != '' && method_exists($authobj, 'change_password')) {
$authobj->change_password($userobj, $user->password, $resetpasswordchange);
}
else {
......
......@@ -1779,6 +1779,8 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul
$userobj->find_by_id($user->id);
$userobj->copy_views(get_column('view', 'id', 'institution', 'mahara', 'copynewuser', 1), $checkviewaccess);
reset_password($user, false);
handle_event('createuser', $user);
db_commit();
return $user->id;
......
......@@ -108,7 +108,6 @@ if (isset($key)) {
$user->email = $registration->email;
$user->username = get_new_username($user->firstname . $user->lastname);
$user->passwordchange = 1;
$user->salt = substr(md5(rand(1000000, 9999999)), 2, 8);
create_user($user, $profilefields);
......
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