Make it work

This commit is contained in:
Kumi 2022-08-20 10:38:31 +00:00
parent d95a7dd13a
commit 307d2a2d53
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 12 additions and 4 deletions

View file

@ -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);
}
}
}

View file

@ -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)