mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-41170 events: User_updated event should be triggered on password updates
This commit is contained in:
parent
835a006b07
commit
6c679d1532
3 changed files with 58 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue