Add optional to control wether a welcome mail should be send after a registration by social network
This commit is contained in:
@ -148,6 +148,10 @@ register by throwing a `NotFoundHttpException` if the `RegistrationController::a
|
|||||||
Setting this attribute allows the registration process via social networks. If you set it to `false`, the module won't allow users to
|
Setting this attribute allows the registration process via social networks. If you set it to `false`, the module won't allow users to
|
||||||
register.
|
register.
|
||||||
|
|
||||||
|
#### sendWelcomeMailAfterSocialNetworkRegistration (type: `boolean`, default: `true`)
|
||||||
|
|
||||||
|
Setting this attribute controls wether a confirmation mail should be send or not.
|
||||||
|
|
||||||
#### enableEmailConfirmation (type: `boolean`, default: `true`)
|
#### enableEmailConfirmation (type: `boolean`, default: `true`)
|
||||||
|
|
||||||
If `true`, the module will send an email with a confirmation link that user needs to click through to complete its
|
If `true`, the module will send an email with a confirmation link that user needs to click through to complete its
|
||||||
|
|||||||
@ -17,6 +17,7 @@ use Da\User\Event\UserEvent;
|
|||||||
use Da\User\Factory\MailFactory;
|
use Da\User\Factory\MailFactory;
|
||||||
use Da\User\Form\RegistrationForm;
|
use Da\User\Form\RegistrationForm;
|
||||||
use Da\User\Form\ResendForm;
|
use Da\User\Form\ResendForm;
|
||||||
|
use Da\User\Helper\SecurityHelper;
|
||||||
use Da\User\Model\SocialNetworkAccount;
|
use Da\User\Model\SocialNetworkAccount;
|
||||||
use Da\User\Model\User;
|
use Da\User\Model\User;
|
||||||
use Da\User\Query\SocialNetworkAccountQuery;
|
use Da\User\Query\SocialNetworkAccountQuery;
|
||||||
@ -175,7 +176,11 @@ class RegistrationController extends Controller
|
|||||||
if ($user->load(Yii::$app->request->post()) && $user->validate()) {
|
if ($user->load(Yii::$app->request->post()) && $user->validate()) {
|
||||||
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_CONNECT, $event);
|
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_CONNECT, $event);
|
||||||
|
|
||||||
|
if ($this->module->sendWelcomeMailAfterSocialNetworkRegistration) {
|
||||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||||
|
} else {
|
||||||
|
$mailService = null;
|
||||||
|
}
|
||||||
if ($this->make(UserCreateService::class, [$user, $mailService])->run()) {
|
if ($this->make(UserCreateService::class, [$user, $mailService])->run()) {
|
||||||
$account->connect($user);
|
$account->connect($user);
|
||||||
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_CONNECT, $event);
|
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_CONNECT, $event);
|
||||||
|
|||||||
@ -121,6 +121,10 @@ class Module extends BaseModule
|
|||||||
* @var bool whether to allow registration process for social network or not
|
* @var bool whether to allow registration process for social network or not
|
||||||
*/
|
*/
|
||||||
public $enableSocialNetworkRegistration = true;
|
public $enableSocialNetworkRegistration = true;
|
||||||
|
/**
|
||||||
|
* @var bool whether to send a welcome mail after the registration process for social network
|
||||||
|
*/
|
||||||
|
public $sendWelcomeMailAfterSocialNetworkRegistration = true;
|
||||||
/**
|
/**
|
||||||
* @var bool whether to force email confirmation to
|
* @var bool whether to force email confirmation to
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class UserCreateService implements ServiceInterface
|
|||||||
protected $securityHelper;
|
protected $securityHelper;
|
||||||
protected $mailService;
|
protected $mailService;
|
||||||
|
|
||||||
public function __construct(User $model, MailService $mailService, SecurityHelper $securityHelper)
|
public function __construct(User $model, ?MailService $mailService, SecurityHelper $securityHelper)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
$this->mailService = $mailService;
|
$this->mailService = $mailService;
|
||||||
@ -70,7 +70,7 @@ class UserCreateService implements ServiceInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$model->trigger(UserEvent::EVENT_AFTER_CREATE, $event);
|
$model->trigger(UserEvent::EVENT_AFTER_CREATE, $event);
|
||||||
if (!$this->sendMail($model)) {
|
if ($this->mailService instanceof MailService && !$this->sendMail($model)) {
|
||||||
$error_msg = Yii::t(
|
$error_msg = Yii::t(
|
||||||
'usuario',
|
'usuario',
|
||||||
'Error sending welcome message to "{email}". Please try again later.',
|
'Error sending welcome message to "{email}". Please try again later.',
|
||||||
|
|||||||
Reference in New Issue
Block a user