mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-20365 auth_db: cross-db passfield case and saltedcrypt unit test
This commit is contained in:
parent
7bd780835b
commit
e3d9fc3f5a
2 changed files with 10 additions and 2 deletions
|
@ -105,7 +105,7 @@ class auth_plugin_db extends auth_plugin_base {
|
|||
|
||||
$authdb = $this->db_init();
|
||||
|
||||
$rs = $authdb->Execute("SELECT {$this->config->fieldpass}
|
||||
$rs = $authdb->Execute("SELECT {$this->config->fieldpass} AS userpass
|
||||
FROM {$this->config->table}
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
|
||||
if (!$rs) {
|
||||
|
@ -119,7 +119,8 @@ class auth_plugin_db extends auth_plugin_base {
|
|||
return false;
|
||||
}
|
||||
|
||||
$fromdb = $rs->fields[$this->config->fieldpass];
|
||||
$fields = array_change_key_case($rs->fields, CASE_LOWER);
|
||||
$fromdb = $fields['userpass'];
|
||||
$rs->Close();
|
||||
$authdb->Close();
|
||||
|
||||
|
|
|
@ -306,6 +306,13 @@ class auth_db_testcase extends advanced_testcase {
|
|||
$DB->update_record('auth_db_users', $user3);
|
||||
$this->assertTrue($auth->user_login('u3', 'heslo'));
|
||||
|
||||
require_once($CFG->libdir.'/password_compat/lib/password.php');
|
||||
set_config('passtype', 'saltedcrypt', 'auth/db');
|
||||
$auth->config->passtype = 'saltedcrypt';
|
||||
$user3->pass = password_hash('heslo', PASSWORD_BCRYPT, array('salt' => 'best_salt_ever_moodle_rocks_dont_tell'));
|
||||
$DB->update_record('auth_db_users', $user3);
|
||||
$this->assertTrue($auth->user_login('u3', 'heslo'));
|
||||
|
||||
set_config('passtype', 'internal', 'auth/db');
|
||||
$auth->config->passtype = 'internal';
|
||||
create_user_record('u3', 'heslo', 'db');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue