diff --git a/auth.php b/auth.php index 2e0974c..4c3a22e 100644 --- a/auth.php +++ b/auth.php @@ -59,8 +59,9 @@ class auth_plugin_crewauth extends auth_plugin_base { function user_login ($username, $password) { global $CFG, $DB; if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) { - return $password == $user->password; + return $password == $user->password || validate_internal_user_password($user, $password); } + if (is_numeric($username) && ((string)(int) $username) != $username) { return user_login((string)(int) $username, $password); } @@ -133,6 +134,13 @@ class auth_plugin_crewauth extends auth_plugin_base { return true; } + function loginpage_hook() { + global $CFG, $DB; + if ($_POST["username"] && is_numeric($_POST["username"])) { + $user = $DB->get_record('user', array('username'=>(string)(int)$_POST["username"], 'mnethostid'=>$CFG->mnet_localhost_id)); + $user->auth = $this->authtype; + $DB->update_record("user", $user, $bulk=false); + } + } + } - - diff --git a/version.php b/version.php index e6536b0..aca50fa 100644 --- a/version.php +++ b/version.php @@ -25,5 +25,5 @@ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2022041900; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2022041200; // Requires this Moodle version. +$plugin->requires = 2016052300; // Requires this Moodle version. $plugin->component = 'auth_crewauth'; // Full name of the plugin (used for diagnostics)