Skip to content

Commit

Permalink
ENH: Add extension hooks to core emails
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglozzer committed May 16, 2022
1 parent 6c3edb2 commit 903dd86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Security/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,16 +914,18 @@ public function onBeforeWrite()
&& static::config()->get('notify_password_change')
&& $this->isInDB()
) {
Email::create()
$email = Email::create()
->setHTMLTemplate('SilverStripe\\Control\\Email\\ChangePasswordEmail')
->setData($this)
->setTo($this->Email)
->setSubject(_t(
__CLASS__ . '.SUBJECTPASSWORDCHANGED',
"Your password has been changed",
'Email subject'
))
->send();
));

$this->extend('updateChangedPasswordEmail', $email);
$email->send();
}

// The test on $this->ID is used for when records are initially created. Note that this only works with
Expand Down
2 changes: 2 additions & 0 deletions src/Security/MemberAuthenticator/LostPasswordHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ protected function sendEmail($member, $token)
))
->addData('PasswordResetLink', Security::getPasswordResetLink($member, $token))
->setTo($member->Email);

$member->extend('updateForgotPasswordEmail', $email);
return $email->send();
}

Expand Down

0 comments on commit 903dd86

Please sign in to comment.