mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Allow new password to save even if there's an error sending email
This commit is contained in:
parent
bf45b0c44b
commit
446810bc5e
@ -4,6 +4,7 @@ namespace SilverStripe\Security;
|
||||
|
||||
use IntlDateFormatter;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
use SilverStripe\CMS\Controllers\CMSMain;
|
||||
use SilverStripe\Control\Director;
|
||||
@ -34,7 +35,9 @@ use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\UnsavedRelationList;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Exception\RfcComplianceException;
|
||||
|
||||
/**
|
||||
* The member class which represents the users of the system
|
||||
@ -772,18 +775,24 @@ class Member extends DataObject
|
||||
&& static::config()->get('notify_password_change')
|
||||
&& $this->isInDB()
|
||||
) {
|
||||
$email = Email::create()
|
||||
->setHTMLTemplate('SilverStripe\\Control\\Email\\ChangePasswordEmail')
|
||||
->setData($this)
|
||||
->setTo($this->Email)
|
||||
->setSubject(_t(
|
||||
__CLASS__ . '.SUBJECTPASSWORDCHANGED',
|
||||
"Your password has been changed",
|
||||
'Email subject'
|
||||
));
|
||||
try {
|
||||
$email = Email::create()
|
||||
->setHTMLTemplate('SilverStripe\\Control\\Email\\ChangePasswordEmail')
|
||||
->setData($this)
|
||||
->setTo($this->Email)
|
||||
->setSubject(_t(
|
||||
__CLASS__ . '.SUBJECTPASSWORDCHANGED',
|
||||
"Your password has been changed",
|
||||
'Email subject'
|
||||
));
|
||||
|
||||
$this->extend('updateChangedPasswordEmail', $email);
|
||||
$email->send();
|
||||
$this->extend('updateChangedPasswordEmail', $email);
|
||||
$email->send();
|
||||
} catch (TransportExceptionInterface | RfcComplianceException $e) {
|
||||
/** @var LoggerInterface $logger */
|
||||
$logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler');
|
||||
$logger->error('Error sending email in ' . __FILE__ . ' line ' . __LINE__ . ": {$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
// The test on $this->ID is used for when records are initially created. Note that this only works with
|
||||
|
Loading…
Reference in New Issue
Block a user