From: donal72 Date: Sun, 28 Jan 2007 10:27:05 +0000 (+0000) Subject: Auth: Fix for error creating admin user (if you choose a new username). Also addres... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=da249a302832808a176e366320143c068d5dae55;p=moodle.git Auth: Fix for error creating admin user (if you choose a new username). Also addresses an issue in the user_update_password method. --- diff --git a/auth/db/auth.php b/auth/db/auth.php index 7714725605..1bd81d96fe 100644 --- a/auth/db/auth.php +++ b/auth/db/auth.php @@ -153,11 +153,11 @@ class auth_plugin_db { } - function user_update_password($username, $newpassword) { + function user_update_password($user, $newpassword) { global $CFG; if ($this->config->passtype === 'internal') { - return set_field('user', 'password', md5($newpassword), 'username', $username, 'mnethostid', $CFG->mnet_localhost_id); + return set_field('user', 'password', md5($newpassword), 'id', $user->id, 'mnethostid', $CFG->mnet_localhost_id); } else { // we should have never been called! return false; diff --git a/auth/email/auth.php b/auth/email/auth.php index 0fba410f8f..f91eb35ad5 100644 --- a/auth/email/auth.php +++ b/auth/email/auth.php @@ -68,8 +68,8 @@ class auth_plugin_email { * @return boolean result * */ - function user_update_password($username, $newpassword) { - $user = get_complete_user_data('username', $username); + function user_update_password($user, $newpassword) { + $user = get_complete_user_data('id', $user->id); return update_internal_user_password($user, $newpassword); } diff --git a/auth/manual/auth.php b/auth/manual/auth.php index 38f3275830..25b862392b 100644 --- a/auth/manual/auth.php +++ b/auth/manual/auth.php @@ -60,8 +60,8 @@ class auth_plugin_manual * @return boolean result * */ - function user_update_password($username, $newpassword) { - $user = get_complete_user_data('username', $username); + function user_update_password($user, $newpassword) { + $user = get_complete_user_data('id', $user->id); return update_internal_user_password($user, $newpassword); } diff --git a/auth/none/auth.php b/auth/none/auth.php index 3fcd2d62c2..b41fea5e90 100644 --- a/auth/none/auth.php +++ b/auth/none/auth.php @@ -61,8 +61,8 @@ class auth_plugin_none { * @return boolean result * */ - function user_update_password($username, $newpassword) { - $user = get_complete_user_data('username', $username); + function user_update_password($user, $newpassword) { + $user = get_complete_user_data('id', $user->id); return update_internal_user_password($user, $newpassword); } diff --git a/login/change_password.php b/login/change_password.php index 0840ef3e6d..f9e55c4e12 100644 --- a/login/change_password.php +++ b/login/change_password.php @@ -57,7 +57,7 @@ // load the appropriate auth plugin $userauth = get_auth_plugin($user->auth); if ($userauth->can_change_password()){ - if ($userauth->user_update_password($user->username, $data->newpassword1)) { + if ($userauth->user_update_password($user, $data->newpassword1)) { // hash the $user->password field (without local db update) update_internal_user_password($user, $data->newpassword1, false); } else { diff --git a/user/editadvanced.php b/user/editadvanced.php index f159a31784..bd4e2f28d8 100644 --- a/user/editadvanced.php +++ b/user/editadvanced.php @@ -97,7 +97,7 @@ if (!empty($usernew->newpassword)) { if ($authplugin->can_change_password()) { if (method_exists($authplugin, 'user_update_password')){ - if (!$authplugin->user_update_password($user->username, $usernew->newpassword)){ + if (!$authplugin->user_update_password($usernew, $usernew->newpassword)){ error('Failed to update password on external auth: ' . $usernew->auth . '. See the server logs for more details.'); }