From 4447121fbab2d1b4e03784bdfd3e1341a5c81178 Mon Sep 17 00:00:00 2001 From: mateuszdebinski <58430570+mateuszdebinski@users.noreply.github.com> Date: Fri, 3 Apr 2020 18:53:07 +0200 Subject: [PATCH 1/2] =?UTF-8?q?EZP-31195:=20Set=20From=20to=20swiftmailer?= =?UTF-8?q?=20when=20From=20in=20twig=20is=20empty.=20Set=20Fr=E2=80=A6=20?= =?UTF-8?q?(#59)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bundle/Controller/PasswordResetController.php | 15 ++++++++++++--- .../Resources/config/services/controllers.yml | 1 + .../Security/mail/forgot_user_password.html.twig | 1 - .../mail/forgot_user_password.html.twig | 1 - 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/bundle/Controller/PasswordResetController.php b/src/bundle/Controller/PasswordResetController.php index d6a46a6..cad8e78 100644 --- a/src/bundle/Controller/PasswordResetController.php +++ b/src/bundle/Controller/PasswordResetController.php @@ -56,6 +56,9 @@ class PasswordResetController extends Controller /** @var string */ private $forgotPasswordMail; + /** @var string */ + private $senderAddress; + /** * @param \EzSystems\EzPlatformUser\Form\Factory\FormFactory $formFactory * @param \eZ\Publish\API\Repository\UserService $userService @@ -65,6 +68,7 @@ class PasswordResetController extends Controller * @param \eZ\Publish\API\Repository\PermissionResolver $permissionResolver * @param string $tokenIntervalSpec * @param string $forgotPasswordMail + * @param string $senderAddress */ public function __construct( FormFactory $formFactory, @@ -74,7 +78,8 @@ public function __construct( NotificationHandlerInterface $notificationHandler, PermissionResolver $permissionResolver, string $tokenIntervalSpec, - string $forgotPasswordMail + string $forgotPasswordMail, + string $senderAddress = '' ) { $this->formFactory = $formFactory; $this->userService = $userService; @@ -84,6 +89,7 @@ public function __construct( $this->permissionResolver = $permissionResolver; $this->tokenIntervalSpec = $tokenIntervalSpec; $this->forgotPasswordMail = $forgotPasswordMail; + $this->senderAddress = $senderAddress; } /** @@ -249,15 +255,18 @@ private function sendResetPasswordMessage(string $to, string $hashKey): void $template = $this->twig->loadTemplate($this->forgotPasswordMail); $subject = $template->renderBlock('subject', []); - $from = $template->renderBlock('from', []); + $from = $template->renderBlock('from', []) ?: $this->senderAddress; $body = $template->renderBlock('body', ['hashKey' => $hashKey]); $message = (new Swift_Message()) ->setSubject($subject) - ->setFrom($from) ->setTo($to) ->setBody($body, 'text/html'); + if (empty($from) === false) { + $message->setFrom($from); + } + $this->mailer->send($message); } } diff --git a/src/bundle/Resources/config/services/controllers.yml b/src/bundle/Resources/config/services/controllers.yml index 676ec61..0b1f7e2 100644 --- a/src/bundle/Resources/config/services/controllers.yml +++ b/src/bundle/Resources/config/services/controllers.yml @@ -19,6 +19,7 @@ services: arguments: $tokenIntervalSpec: '$security.token_interval_spec$' $forgotPasswordMail: '$user_forgot_password.templates.mail$' + $senderAddress: "@=container.hasParameter('swiftmailer.sender_address') ? parameter('swiftmailer.sender_address') : ''" EzSystems\EzPlatformUserBundle\Controller\PasswordChangeController: autowire: true diff --git a/src/bundle/Resources/views/Security/mail/forgot_user_password.html.twig b/src/bundle/Resources/views/Security/mail/forgot_user_password.html.twig index d7c369e..a2164cb 100644 --- a/src/bundle/Resources/views/Security/mail/forgot_user_password.html.twig +++ b/src/bundle/Resources/views/Security/mail/forgot_user_password.html.twig @@ -1,5 +1,4 @@ {%- block from -%} - noreply@domain.com {%- endblock from -%} {%- block subject -%} diff --git a/src/bundle/Resources/views/forgot_password/mail/forgot_user_password.html.twig b/src/bundle/Resources/views/forgot_password/mail/forgot_user_password.html.twig index 3451723..a274307 100644 --- a/src/bundle/Resources/views/forgot_password/mail/forgot_user_password.html.twig +++ b/src/bundle/Resources/views/forgot_password/mail/forgot_user_password.html.twig @@ -1,7 +1,6 @@ {% trans_default_domain 'forgot_password' %} {%- block from -%} - noreply@domain.com {%- endblock from -%} {%- block subject -%} From 05d16ed83c406f08ee33343d134950675a159d86 Mon Sep 17 00:00:00 2001 From: "mikolaj.karaczyn" Date: Wed, 6 May 2020 12:13:52 +0200 Subject: [PATCH 2/2] [Travis] Changed notification key after rebranding --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3243828..0990408 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ script: notifications: slack: rooms: - - secure: WHaF3LihH1WgOrdo7XCVooAjCED48eBo5T7wuDLIHxZzEHZnRx+cwUe0ta4/m/hjAl1kXmfay0nwCnvjEPCOGN45SnA5yAOVsR0ExFr9QYCUlh967a5a6ckagdO6S8alqFmVaUhhTrfLOO4yorr7cdHr0n3l0U/vm4QA3+40vPsZH4C7+Z80i9EFt2IPGzwDamVIXGaBS5AkJyYYT9PAwv2XYdUJDy+jWP0a1w2PbCWGzGLnIYJ472kzzUfPMoTmNpqRkvTyoNToJ+mfW24FssjB05eLwbcy8FDBYH+BrM88uKG6TgAyAOfUuA/EzMooe5cQs3faneExFxxt3aLwRde3OLJJtNUFCNwRUqD3IXQCDZVlqUfkuo0/2NTjeDAb08qNOyi0/dCBLYedeOEfYqGhhc7WYITKHTtXKCQMI4GbMxWVDMSo9wpXgoaCwCVP5LBbiHrwe5Vr4NzQmOwwcIC4IGVW2z2GT1JQ5uahMJ1klITlxn+rCBdE8dde6OFVNiS7UUnI7r6hMHoaUlWV8n1pb8cYH9ZubEUjZzZ5RFu8cFX/Q52Rk3n5AYSWIqcMF94sGj1TsHw2b+ex+GWYMVhXQ1hvx2YwF5PtMY9oKuzcwntAKYvNWMIdBU8M4UFdLxChSBwcNhJPQ9435qlgNkee/836d1FuL42LCyfvi8I= + - secure: EaR+jN0IrmT71U6ahNLepHApB3A6PXlPwK+hwaMcId1c1IuwcalACMYNIqjIQr0cvHpTH7PGM2TtR648i9hRn+CrGDZZU6448T5Vh72E+1KiZ79rXByHr/a27onp5Lx5NSKlSila/bjWT+qsvJ/fUy+RLK42vVVCUrdbE2hvwLoOvUtiaPVyJU+TXzq9uIERoS+lknwVP/HMbXQ8k3h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