Add optional to control wether a welcome mail should be send after a registration by social network

This commit is contained in:
Elias Luhr
2024-01-05 15:49:25 +01:00
parent e5d5ea426d
commit 8a81ad7c42
4 changed files with 16 additions and 3 deletions

View File

@ -31,7 +31,7 @@ class UserCreateService implements ServiceInterface
protected $securityHelper;
protected $mailService;
public function __construct(User $model, MailService $mailService, SecurityHelper $securityHelper)
public function __construct(User $model, ?MailService $mailService, SecurityHelper $securityHelper)
{
$this->model = $model;
$this->mailService = $mailService;
@ -70,7 +70,7 @@ class UserCreateService implements ServiceInterface
}
$model->trigger(UserEvent::EVENT_AFTER_CREATE, $event);
if (!$this->sendMail($model)) {
if ($this->mailService instanceof MailService && !$this->sendMail($model)) {
$error_msg = Yii::t(
'usuario',
'Error sending welcome message to "{email}". Please try again later.',