Merge branch 'w41_MDL-35695_m24_authdb' of git://github.com/skodak/moodle
This commit is contained in:
+14
-2
@@ -46,12 +46,22 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
$extusername = textlib::convert($username, 'utf-8', $this->config->extencoding);
|
||||
$extpassword = textlib::convert($password, 'utf-8', $this->config->extencoding);
|
||||
|
||||
$authdb = $this->db_init();
|
||||
|
||||
if ($this->is_internal()) {
|
||||
// lookup username externally, but resolve
|
||||
// password locally -- to support backend that
|
||||
// don't track passwords
|
||||
|
||||
if (isset($this->config->removeuser) and $this->config->removeuser == AUTH_REMOVEUSER_KEEP) {
|
||||
// No need to connect to external database in this case because users are never removed and we verify password locally.
|
||||
if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'auth'=>$this->authtype))) {
|
||||
return validate_internal_user_password($user, $password);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$authdb = $this->db_init();
|
||||
|
||||
$rs = $authdb->Execute("SELECT * FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."' ");
|
||||
if (!$rs) {
|
||||
@@ -78,6 +88,8 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
} else {
|
||||
// normal case: use external db for both usernames and passwords
|
||||
|
||||
$authdb = $this->db_init();
|
||||
|
||||
if ($this->config->passtype === 'md5') { // Re-format password accordingly
|
||||
$extpassword = md5($extpassword);
|
||||
} else if ($this->config->passtype === 'sha1') {
|
||||
|
||||
Reference in New Issue
Block a user