From 6b585c3fc288451792a7e2e8d67e6b36faf29034 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Fri, 13 May 2022 09:18:24 +0100 Subject: [PATCH] ENH: Add extension hooks to core emails --- src/Security/Member.php | 8 +++++--- src/Security/MemberAuthenticator/LostPasswordHandler.php | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Security/Member.php b/src/Security/Member.php index 7f06edf13d4..40b3ee5774b 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -914,7 +914,7 @@ 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) @@ -922,8 +922,10 @@ public function onBeforeWrite() __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 diff --git a/src/Security/MemberAuthenticator/LostPasswordHandler.php b/src/Security/MemberAuthenticator/LostPasswordHandler.php index 8174ab477dc..524430c0575 100644 --- a/src/Security/MemberAuthenticator/LostPasswordHandler.php +++ b/src/Security/MemberAuthenticator/LostPasswordHandler.php @@ -242,6 +242,8 @@ protected function sendEmail($member, $token) )) ->addData('PasswordResetLink', Security::getPasswordResetLink($member, $token)) ->setTo($member->Email); + + $this->extend('updateForgotPasswordEmail', $email, $member); return $email->send(); }