aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php16
-rw-r--r--src/Wallabag/UserBundle/Resources/config/services.yml1
-rw-r--r--src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml10
-rw-r--r--src/Wallabag/UserBundle/Resources/translations/wallabag_user.fr.yml10
-rw-r--r--src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig35
-rw-r--r--src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php15
6 files changed, 51 insertions, 36 deletions
diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
index fa682ae7..6b108dd3 100644
--- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
+++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
@@ -47,6 +47,13 @@ class AuthCodeMailer implements AuthCodeMailerInterface
47 private $supportUrl; 47 private $supportUrl;
48 48
49 /** 49 /**
50 * Url for the wallabag instance.
51 *
52 * @var string
53 */
54 private $wallabagUrl;
55
56 /**
50 * Initialize the auth code mailer with the SwiftMailer object. 57 * Initialize the auth code mailer with the SwiftMailer object.
51 * 58 *
52 * @param \Swift_Mailer $mailer 59 * @param \Swift_Mailer $mailer
@@ -54,14 +61,16 @@ class AuthCodeMailer implements AuthCodeMailerInterface
54 * @param string $senderEmail 61 * @param string $senderEmail
55 * @param string $senderName 62 * @param string $senderName
56 * @param string $supportUrl 63 * @param string $supportUrl
64 * @param string $wallabagUrl
57 */ 65 */
58 public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, $supportUrl) 66 public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, $supportUrl, $wallabagUrl)
59 { 67 {
60 $this->mailer = $mailer; 68 $this->mailer = $mailer;
61 $this->twig = $twig; 69 $this->twig = $twig;
62 $this->senderEmail = $senderEmail; 70 $this->senderEmail = $senderEmail;
63 $this->senderName = $senderName; 71 $this->senderName = $senderName;
64 $this->supportUrl = $supportUrl; 72 $this->supportUrl = $supportUrl;
73 $this->wallabagUrl = $wallabagUrl;
65 } 74 }
66 75
67 /** 76 /**
@@ -77,12 +86,13 @@ class AuthCodeMailer implements AuthCodeMailerInterface
77 $bodyHtml = $template->renderBlock('body_html', [ 86 $bodyHtml = $template->renderBlock('body_html', [
78 'user' => $user->getName(), 87 'user' => $user->getName(),
79 'code' => $user->getEmailAuthCode(), 88 'code' => $user->getEmailAuthCode(),
80 'support' => $this->supportUrl, 89 'support_url' => $this->supportUrl,
90 'wallabag_url' => $this->wallabagUrl,
81 ]); 91 ]);
82 $bodyText = $template->renderBlock('body_text', [ 92 $bodyText = $template->renderBlock('body_text', [
83 'user' => $user->getName(), 93 'user' => $user->getName(),
84 'code' => $user->getEmailAuthCode(), 94 'code' => $user->getEmailAuthCode(),
85 'support' => $this->supportUrl, 95 'support_url' => $this->supportUrl,
86 ]); 96 ]);
87 97
88 $message = new \Swift_Message(); 98 $message = new \Swift_Message();
diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml
index aa2fd8b9..93e04d59 100644
--- a/src/Wallabag/UserBundle/Resources/config/services.yml
+++ b/src/Wallabag/UserBundle/Resources/config/services.yml
@@ -7,3 +7,4 @@ services:
7 - "%scheb_two_factor.email.sender_email%" 7 - "%scheb_two_factor.email.sender_email%"
8 - "%scheb_two_factor.email.sender_name%" 8 - "%scheb_two_factor.email.sender_name%"
9 - "%wallabag_support_url%" 9 - "%wallabag_support_url%"
10 - "%wallabag_url%"
diff --git a/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml
index 7298bb28..4da6075f 100644
--- a/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml
+++ b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.en.yml
@@ -1,9 +1,7 @@
1# Two factor mail 1# Two factor mail
2auth_code.mailer.subject: 'Wallabag authentication Code' 2auth_code.mailer.subject: 'Wallabag authentication Code'
3auth_code.mailer.body.hello: "Hi %user%," 3auth_code.mailer.body.hello: "Hi %user%,"
4auth_code.mailer.body.content: | 4auth_code.mailer.body.first_para: "Since you enable two factor authentication on your wallabag account and you just logged in from a new device (computer, phone, etc.), we send you a code to validate your connection."
5 Since you enable two factor authentication on your wallabag account and you just logged in from a new device (computer, phone, etc.), we send you a code to validate your connection. 5auth_code.mailer.body.second_para: "Here is the code:"
6 Here is the code: %code% 6auth_code.mailer.body.support: "Please don't hesitate to contact us if you have any problems:"
7auth_code.mailer.body.signature: | 7auth_code.mailer.body.signature: "The wallabag team"
8 Please don't hesitate to contact us if you have any problems: %support%
9 The wallabag team
diff --git a/src/Wallabag/UserBundle/Resources/translations/wallabag_user.fr.yml b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.fr.yml
index 0c492d04..b4448d3a 100644
--- a/src/Wallabag/UserBundle/Resources/translations/wallabag_user.fr.yml
+++ b/src/Wallabag/UserBundle/Resources/translations/wallabag_user.fr.yml
@@ -1,9 +1,7 @@
1# Two factor mail 1# Two factor mail
2auth_code.mailer.subject: "Code d'authentification wallabag" 2auth_code.mailer.subject: "Code d'authentification wallabag"
3auth_code.mailer.body.hello: "Bonjour %user%," 3auth_code.mailer.body.hello: "Bonjour %user%,"
4auth_code.mailer.body.content: | 4auth_code.mailer.body.first_para: "Comme vous avez activé la double authentification sur votre compte wallabag et que vous venez de vous connecter depuis un nouvel appareil (ordinateur, téléphone, etc.), nous vous envoyons un code pour valider votre connexion."
5 Comme vous avez activé la double authentification sur votre compte wallabag et que vous venez de vous connecter depuis un nouvel appareil (ordinateur, téléphone, etc.), nous vous envoyons un code pour valider votre connexion. 5auth_code.mailer.body.second_para: "Voici le code à renseigner :"
6 Voici le code à renseigner: %code% 6auth_code.mailer.body.support: "Si vous avez un problème de connexion, n'hésitez pas à contacter le support :"
7auth_code.mailer.body.signature: | 7auth_code.mailer.body.signature: "L'équipe wallabag"
8 Si vous avez un problème de connexion, n'hésitez pas à contacter le support: %support%
9 L'équipe wallabag
diff --git a/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig b/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig
index 849cd136..69d23160 100644
--- a/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig
+++ b/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig
@@ -2,6 +2,17 @@
2{{ "auth_code.mailer.subject"|trans({}, 'wallabag_user') }} 2{{ "auth_code.mailer.subject"|trans({}, 'wallabag_user') }}
3{% endblock %} 3{% endblock %}
4 4
5{% block body_text %}
6{{ "auth_code.mailer.body.hello"|trans({'%user%': user}, 'wallabag_user') }}
7
8{{ "auth_code.mailer.body.first_para"|trans({}, 'wallabag_user') }}
9{{ "auth_code.mailer.body.second_para"|trans({}, 'wallabag_user') }} {{ code }}
10
11{{ "auth_code.mailer.body.support"|trans({}, 'wallabag_user') }} {{ support_url }}
12
13{{ "auth_code.mailer.body.signature"|trans({}, 'wallabag_user') }}
14{% endblock %}
15
5{% block body_html %} 16{% block body_html %}
6<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 17<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7 18
@@ -63,10 +74,10 @@
63 74
64 <table cellpadding="0" cellspacing="0" border="0" align="center" id="card"> 75 <table cellpadding="0" cellspacing="0" border="0" align="center" id="card">
65 <tr> 76 <tr>
66 <td style="padding: 20px;" width="96px" valign="top"><img class="image_fix" src="{ wallabag_url }/themes/material/img/logo-other_themes.png" alt="logo" title="{ wallabag_url }" style="width: 96px; height: 96px;" /></td> 77 <td style="padding: 20px;" width="96px" valign="top"><img class="image_fix" src="{{ wallabag_url }}/themes/material/img/logo-other_themes.png" alt="logo" title="{{ wallabag_url }}" style="width: 96px; height: 96px;" /></td>
67 <td style="padding: 20px; padding-left: 0;" valign="top" id="cell_desc"> 78 <td style="padding: 20px; padding-left: 0;" valign="top" id="cell_desc">
68 <h1>Wallabag</h1> 79 <h1>wallabag</h1>
69 <h5>{% trans %}on{% endtrans %} { wallabag_url }</h5> 80 <h5>{% trans %}on{% endtrans %} {{ wallabag_url }}</h5>
70 </td> 81 </td>
71 </tr> 82 </tr>
72 <tr><td colspan="2" style="padding: 0;"><div style="height: 0; border-top: 1px solid #c5c5c5;">&nbsp;</div></td></tr> 83 <tr><td colspan="2" style="padding: 0;"><div style="height: 0; border-top: 1px solid #c5c5c5;">&nbsp;</div></td></tr>
@@ -75,10 +86,11 @@
75 86
76 <p><b>{{ "auth_code.mailer.body.hello"|trans({'%user%': user}, 'wallabag_user') }}</b></p> 87 <p><b>{{ "auth_code.mailer.body.hello"|trans({'%user%': user}, 'wallabag_user') }}</b></p>
77 88
78 <p>{{ "auth_code.mailer.body.content"|trans({'%code%': code}, 'wallabag_user') }}</p> 89 <p>{{ "auth_code.mailer.body.first_para"|trans({}, 'wallabag_user') }}</p>
79 90 <p>{{ "auth_code.mailer.body.second_para"|trans({}, 'wallabag_user') }} <b>{{ code }}</b></p>
80 <p>{{ "auth_code.mailer.body.signature"|trans({'%support%': support}, 'wallabag_user') }}</p>
81 91
92 <p>{{ "auth_code.mailer.body.support"|trans({}, 'wallabag_user') }} <a href="{{ support_url }}">{{ support_url }}</a></p>
93 <p>{{ "auth_code.mailer.body.signature"|trans({}, 'wallabag_user') }}</p>
82 </td> 94 </td>
83 </tr> 95 </tr>
84 <tr><td colspan="2" style="padding: 0;"><div style="height: 0; border-top: 1px solid #c5c5c5;">&nbsp;</div></td></tr> 96 <tr><td colspan="2" style="padding: 0;"><div style="height: 0; border-top: 1px solid #c5c5c5;">&nbsp;</div></td></tr>
@@ -87,8 +99,8 @@
87 99
88 <table cellpadding="0" cellspacing="0" border="0" width="100%"> 100 <table cellpadding="0" cellspacing="0" border="0" width="100%">
89 <tr> 101 <tr>
90 <td valign="top" style="padding: 20px; text-align: center"><a href="{ wallabag_url }">{ wallabag_url }</a></td> 102 <td valign="top" style="padding: 20px; text-align: center"><a href="{{ wallabag_url }}">{{ wallabag_url }}</a></td>
91 <td valign="top" style="padding: 20px; text-align: center">Powered by <a href="https://www.wallabag.org/">Wallabag</a></td> 103 <td valign="top" style="padding: 20px; text-align: center">Powered by <a href="https://www.wallabag.org/">wallabag</a></td>
92 </tr> 104 </tr>
93 </table> 105 </table>
94 106
@@ -103,10 +115,3 @@
103</body> 115</body>
104</html> 116</html>
105{% endblock %} 117{% endblock %}
106
107{% block body_text %}
108{{ "auth_code.mailer.body.hello"|trans({'%user%': user}, 'wallabag_user') }}
109
110{{ "auth_code.mailer.body.content"|trans({'%code%': code}, 'wallabag_user') }}
111{{ "auth_code.mailer.body.signature"|trans({'%support%': support}, 'wallabag_user') }}
112{% endblock %}
diff --git a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php
index fbd7fdd7..e3f43a7e 100644
--- a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php
+++ b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php
@@ -36,11 +36,13 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
36 ); 36 );
37 $this->mailer = new \Swift_Mailer($transport); 37 $this->mailer = new \Swift_Mailer($transport);
38 38
39 $this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('@WallabagUserBundle/Resources/views/TwoFactor/email_auth_code.html.twig' => ' 39 $twigTemplate = <<<TWIG
40{% block subject %}subject{% endblock %} 40{% block subject %}subject{% endblock %}
41{% block body_html %}html body{% endblock %} 41{% block body_html %}html body {{ code }}{% endblock %}
42{% block body_text %}text body{% endblock %} 42{% block body_text %}text body {{ support_url }}{% endblock %}
43'))); 43TWIG;
44
45 $this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('@WallabagUserBundle/Resources/views/TwoFactor/email_auth_code.html.twig' => $twigTemplate)));
44 } 46 }
45 47
46 public function testSendEmail() 48 public function testSendEmail()
@@ -56,6 +58,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
56 $this->twig, 58 $this->twig,
57 'nobody@test.io', 59 'nobody@test.io',
58 'wallabag test', 60 'wallabag test',
61 'http://0.0.0.0/support',
59 'http://0.0.0.0' 62 'http://0.0.0.0'
60 ); 63 );
61 64
@@ -67,7 +70,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
67 $this->assertArrayHasKey('test@wallabag.io', $msg->getTo()); 70 $this->assertArrayHasKey('test@wallabag.io', $msg->getTo());
68 $this->assertEquals(array('nobody@test.io' => 'wallabag test'), $msg->getFrom()); 71 $this->assertEquals(array('nobody@test.io' => 'wallabag test'), $msg->getFrom());
69 $this->assertEquals('subject', $msg->getSubject()); 72 $this->assertEquals('subject', $msg->getSubject());
70 $this->assertContains('text body', $msg->toString()); 73 $this->assertContains('text body http://0.0.0.0/support', $msg->toString());
71 $this->assertContains('html body', $msg->toString()); 74 $this->assertContains('html body 666666', $msg->toString());
72 } 75 }
73} 76}