From 8886ee0942fe57a84fb51617faaa3178f0a34a60 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 15 Jul 2005 11:11:08 +0000 Subject: [PATCH] Updated preventpassindb to work properly. (sometimes db password wasn't being updated to 'not cached' properly). --- lib/moodlelib.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index a30e48c4905..27d51dc96da 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2390,14 +2390,13 @@ function authenticate_user_login($username, $password) { if (empty($user->auth)) { // For some reason auth isn't set yet set_field('user', 'auth', $auth, 'username', $username); } - if ($md5password <> $user->password) { // Update local copy of password for reference - if(empty($CFG->{$user->auth.'_preventpassindb'})){ //Prevent passwords in Moodle's DB - set_field('user', 'password', $md5password, 'username', $username); - } else { - if ($user->password != 'not cached') { - set_field('user', 'password', 'not cached', 'username', $username); //Unusable password - } - } + if (empty($CFG->{$user->auth.'_preventpassindb'})){ //Calculate the password to update + $passfield = $md5password; + } else { + $passfield = 'not cached'; + } + if ($passfield <> $user->password) { // Update local copy of password for reference + set_field('user', 'password', $passfield, 'username', $username); //Update password } if (!is_internal_auth()) { // update user record from external DB $user = update_user_record($username);