diff --git a/src/bundle/Controller/PasswordResetController.php b/src/bundle/Controller/PasswordResetController.php index 01edfdac..6135aef8 100644 --- a/src/bundle/Controller/PasswordResetController.php +++ b/src/bundle/Controller/PasswordResetController.php @@ -31,6 +31,7 @@ use Ibexa\User\View\ResetPassword\FormView as UserResetPasswordFormView; use Ibexa\User\View\ResetPassword\InvalidLinkView; use Ibexa\User\View\ResetPassword\SuccessView as UserResetPasswordSuccessView; +use Swift_Image; use Swift_Mailer; use Swift_Message; use Symfony\Component\HttpFoundation\Request; @@ -82,6 +83,7 @@ public function __construct( */ public function userForgotPasswordAction(Request $request, ?string $reason = null) { + $form = $this->formFactory->forgotUserPassword(); $form->handleRequest($request); @@ -249,12 +251,19 @@ private function sendResetPasswordMessage(User $user, string $hashKey): void $subject = $template->renderBlock('subject', []); $from = $template->renderBlock('from', []) ?: $senderAddress; - $body = $template->renderBlock('body', ['hash_key' => $hashKey]); $message = (new Swift_Message()) ->setSubject($subject) - ->setTo($user->email) - ->setBody($body, 'text/html'); + ->setTo($user->email); + + $mailImagesDir = dirname(__DIR__, 6) . '/public/bundles/ibexaadminui/img/mail/'; + $embeddedHeader = $message->embed(Swift_Image::fromPath($mailImagesDir . 'header.png')); + + $body = $template->renderBlock('body', [ + 'hash_key' => $hashKey, + 'header_img_path' => $embeddedHeader, + ]); + $message->setBody($body, 'text/html'); if (empty($from) === false) { $message->setFrom($from); diff --git a/src/bundle/Resources/translations/ibexa_forgot_password.en.xliff b/src/bundle/Resources/translations/ibexa_forgot_password.en.xliff index a42560e0..1897b22b 100644 --- a/src/bundle/Resources/translations/ibexa_forgot_password.en.xliff +++ b/src/bundle/Resources/translations/ibexa_forgot_password.en.xliff @@ -16,23 +16,6 @@ This email is connected with several accounts. Enter your username instead. key: ezplatform.forgot_password.login - -
- We have received a request to reset the password for your account. Click “reset password” below to choose a new password: -

- Reset password -

- If you did not request a password reset, please ignore this email, and your password will remain the same.]]> -
- We have received a request to reset the password for your account. Click “reset password” below to choose a new password: -

-
Reset password -

- If you did not request a password reset, please ignore this email, and your password will remain the same.]]> - key: ezplatform.forgot_password.message -
Reset your password Reset your password @@ -54,6 +37,31 @@

If you reset your password multiple times, only the most recent password reset link will be valid.

]]> key: ezplatform.forgot_password.success
+ + We have received a request to reset the password for your account. Click "reset password" below to choose a new password: + We have received a request to reset the password for your account. Click "reset password" below to choose a new password: + key: forgot_user_password.mail.message + + + If you did not request a password reset, please ignore this email, and your password will remain the same. + If you did not request a password reset, please ignore this email, and your password will remain the same. + key: forgot_user_password.mail.message_footer + + + Hello, + Hello, + key: forgot_user_password.mail.message_title + + + Reset password + Reset password + key: forgot_user_password.mail.reset_password + + + Reset your password + Reset your password + key: forgot_user_password.mail.reset_your_password + diff --git a/src/bundle/Resources/translations/ibexa_user_invitation.en.xliff b/src/bundle/Resources/translations/ibexa_user_invitation.en.xliff index 0659726a..9f8bed05 100644 --- a/src/bundle/Resources/translations/ibexa_user_invitation.en.xliff +++ b/src/bundle/Resources/translations/ibexa_user_invitation.en.xliff @@ -6,6 +6,11 @@ The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message. + + Join + Join + key: ibexa.user.invitation.mail.join + Hello, Join us at: %invite_link% @@ -15,6 +20,11 @@ key: ibexa.user.invitation.mail.message + + Hello, + Hello, + key: ibexa.user.invitation.mail.message_title + You are invited to join You are invited to join 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 94fd30dc..12bd3fe1 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,21 +1,28 @@ -{% trans_default_domain 'ibexa_forgot_password' %} +{% extends '@ibexadesign/ui/mail/base_mail_template.html.twig' %} -{%- block from -%} -{%- endblock from -%} +{% trans_default_domain 'ibexa_forgot_password' %} {%- block subject -%} - {{ 'ezplatform.forgot_password.reset_your_password'|trans|desc('Reset your password') }} + {{ 'forgot_user_password.mail.reset_your_password'|trans|desc('Reset your password') }} {%- endblock subject -%} -{%- block body -%} -

- {{ 'ezplatform.forgot_password.message'|trans({ '%reset_password%': url('ibexa.user.reset_password', {'hashKey': hash_key}) })|raw - |desc('Hello, -

- We have received a request to reset the password for your account. Click “reset password” below to choose a new password: -

-
Reset password -

- If you did not request a password reset, please ignore this email, and your password will remain the same.') }} -

-{%- endblock body -%} +{%- block mail_message_title_content -%} + {{ 'forgot_user_password.mail.message_title'|trans()|desc('Hello,') }} +{%- endblock mail_message_title_content -%} + +{%- block mail_message_content %} + {{ 'forgot_user_password.mail.message'|trans()|desc('We have received a request to reset the password for your account. Click "reset password" below to choose a new password:') }} +{%- endblock mail_message_content %} + +{%- block mail_actions_content -%} + {% include '@ibexadesign/ui/mail/action_btn.html.twig' with { + url: url('ibexa.user.reset_password', { + 'hashKey': hash_key + }), + label: 'forgot_user_password.mail.reset_password'|trans()|desc('Reset password') + } %} +{%- endblock mail_actions_content -%} + +{%- block mail_footer_content -%} + {{ 'forgot_user_password.mail.message_footer'|trans()|desc('If you did not request a password reset, please ignore this email, and your password will remain the same.') }} +{%- endblock mail_footer_content -%} diff --git a/src/bundle/Resources/views/invitation/mail/user_invitation.html.twig b/src/bundle/Resources/views/invitation/mail/user_invitation.html.twig index 1b446870..ed6e21c2 100644 --- a/src/bundle/Resources/views/invitation/mail/user_invitation.html.twig +++ b/src/bundle/Resources/views/invitation/mail/user_invitation.html.twig @@ -1,22 +1,27 @@ -{% trans_default_domain 'ibexa_user_invitation' %} +{% extends '@ibexadesign/ui/mail/base_mail_template.html.twig' %} -{%- block from -%} -{%- endblock from -%} +{% trans_default_domain 'ibexa_user_invitation' %} {%- block subject -%} {{ 'ibexa.user.invitation.mail.subject'|trans|desc('You are invited to join') }} {%- endblock subject -%} -{%- block body -%} -

- {{ 'ibexa.user.invitation.mail.message'|trans({ - '%invite_link%': url('ibexa.user.from_invite.register', { - 'inviteHash': invite_hash, - 'siteaccess': siteaccess - }) - })|raw - |desc('Hello, - Join us at: %invite_link% - ') }} -

-{%- endblock body -%} +{%- block mail_message_title_content -%} + {{ 'ibexa.user.invitation.mail.message_title'|trans()|desc('Hello,') }} +{%- endblock mail_message_title_content -%} + +{%- block mail_message_content -%} + {{ 'ibexa.user.invitation.mail.message'|trans()|desc('Join us at:') }} +{%- endblock mail_message_content -%} + +{%- block mail_actions_conten -%} + {% include '@ibexadesign/ui/mail/action_btn.html.twig' with { + url: url('ibexa.user.from_invite.register', { + 'inviteHash': invite_hash, + 'siteaccess': siteaccess + }), + label: 'ibexa.user.invitation.mail.join'|trans()|desc('Join') + } %} +{%- endblock mail_actions_conten -%} + +{%- block mail_footer -%}{%- endblock mail_footer -%} diff --git a/src/lib/Invitation/MailSender.php b/src/lib/Invitation/MailSender.php index 2714ea60..ed5e4afd 100644 --- a/src/lib/Invitation/MailSender.php +++ b/src/lib/Invitation/MailSender.php @@ -13,6 +13,7 @@ use Ibexa\Contracts\User\Invitation\InvitationSender; use Swift_Mailer; use Swift_Message; +use Swift_Image; use Twig\Environment; final class MailSender implements InvitationSender @@ -49,16 +50,26 @@ public function sendInvitation(Invitation $invitation): void $subject = $template->renderBlock('subject', []); $from = $template->renderBlock('from', []) ?: $senderAddress; + + $message = (new Swift_Message()) + ->setSubject($subject) + ->setTo($invitation->getEmail()); + + $mailImagesDir = dirname(__DIR__, 6) . '/public/bundles/ibexaadminui/img/mail/'; + $embeddedHeader = $message->embed(Swift_Image::fromPath($mailImagesDir . 'header.jpg')); + $embeddedBtnPrimaryLeftSide = $message->embed(Swift_Image::fromPath($mailImagesDir .'btn_primary_left_side.jpg')); + $embeddedBtnPrimaryRightSide = $message->embed(Swift_Image::fromPath($mailImagesDir .'btn_primary_right_side.jpg')); + $body = $template->renderBlock('body', [ 'invite_hash' => $invitation->getHash(), 'siteaccess' => $invitation->getSiteAccessIdentifier(), 'invitation' => $invitation, + 'header_path' => $embeddedHeader, + 'btn_primary_left_side' => $embeddedBtnPrimaryLeftSide, + 'btn_primary_right_side' => $embeddedBtnPrimaryRightSide, ]); - $message = (new Swift_Message()) - ->setSubject($subject) - ->setTo($invitation->getEmail()) - ->setBody($body, 'text/html'); + $message->setBody($body, 'text/html'); if (empty($from) === false) { $message->setFrom($from);