Auth: Fix for error creating admin user (if you choose a new username). Also addres...
authordonal72 <donal72>
Sun, 28 Jan 2007 10:27:05 +0000 (10:27 +0000)
committerdonal72 <donal72>
Sun, 28 Jan 2007 10:27:05 +0000 (10:27 +0000)
auth/db/auth.php
auth/email/auth.php
auth/manual/auth.php
auth/none/auth.php
login/change_password.php
user/editadvanced.php

index 7714725..1bd81d9 100644 (file)
@@ -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;
index 0fba410..f91eb35 100644 (file)
@@ -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);
     }
 
index 38f3275..25b8623 100644 (file)
@@ -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);
     }
 
index 3fcd2d6..b41fea5 100644 (file)
@@ -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);
     }
 
index 0840ef3..f9e55c4 100644 (file)
@@ -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 {
index f159a31..bd4e2f2 100644 (file)
@@ -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.');
                         }