MDL-41170 events: User_updated event should be triggered on password updates

This commit is contained in:
Ankit Agarwal 2013-10-07 17:27:45 +08:00
parent 835a006b07
commit 6c679d1532
3 changed files with 58 additions and 0 deletions

View file

@ -4644,6 +4644,14 @@ function update_internal_user_password($user, $password) {
if ($passwordchanged || $algorithmchanged) {
$DB->set_field('user', 'password', $hashedpassword, array('id' => $user->id));
$user->password = $hashedpassword;
// Trigger event.
$event = \core\event\user_updated::create(array(
'objectid' => $user->id,
'context' => context_user::instance($user->id)
));
$event->add_record_snapshot('user', $user);
$event->trigger();
}
return true;
@ -5861,6 +5869,15 @@ function setnew_password_and_mail($user, $fasthash = false) {
$hashedpassword = hash_internal_user_password($newpassword, $fasthash);
$DB->set_field('user', 'password', $hashedpassword, array('id' => $user->id));
$user->password = $hashedpassword;
// Trigger event.
$event = \core\event\user_updated::create(array(
'objectid' => $user->id,
'context' => context_user::instance($user->id)
));
$event->add_record_snapshot('user', $user);
$event->trigger();
$a = new stdClass();
$a->firstname = fullname($user, true);