Merge branch 'wip-MDL-46589-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
@@ -48,7 +48,8 @@ class send_new_user_passwords_task extends scheduled_task {
|
||||
if ($DB->count_records('user_preferences', array('name' => 'create_password', 'value' => '1'))) {
|
||||
mtrace('Creating passwords for new users...');
|
||||
$usernamefields = get_all_user_name_fields(true, 'u');
|
||||
$newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email,
|
||||
$newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.auth, u.deleted,
|
||||
u.suspended, u.emailstop, u.mnethostid, u.mailformat,
|
||||
$usernamefields, u.username, u.lang,
|
||||
p.id as prefid
|
||||
FROM {user} u
|
||||
|
||||
@@ -4742,6 +4742,11 @@ function update_internal_user_password($user, $password, $fasthash = false) {
|
||||
require_once($CFG->libdir.'/password_compat/lib/password.php');
|
||||
|
||||
// Figure out what the hashed password should be.
|
||||
if (!isset($user->auth)) {
|
||||
debugging('User record in update_internal_user_password() must include field auth',
|
||||
DEBUG_DEVELOPER);
|
||||
$user->auth = $DB->get_field('user', 'auth', array('id' => $user->id));
|
||||
}
|
||||
$authplugin = get_auth_plugin($user->auth);
|
||||
if ($authplugin->prevent_local_passwords()) {
|
||||
$hashedpassword = AUTH_PASSWORD_NOT_CACHED;
|
||||
|
||||
@@ -2262,6 +2262,13 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->id, $event->relateduserid);
|
||||
$this->assertEquals(context_user::instance($user->id), $event->get_context());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
// Verify recovery of property 'auth'.
|
||||
unset($user->auth);
|
||||
update_internal_user_password($user, 'newpassword');
|
||||
$this->assertDebuggingCalled('User record in update_internal_user_password() must include field auth',
|
||||
DEBUG_DEVELOPER);
|
||||
$this->assertEquals('manual', $user->auth);
|
||||
}
|
||||
|
||||
public function test_fullname() {
|
||||
|
||||
Reference in New Issue
Block a user