Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Add ownCloud motto change password email #34498

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/Controller/LostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,15 @@ protected function sendNotificationMail($userId) {
if ($email !== '') {
$tmpl = new \OC_Template('core', 'lostpassword/notify');
$msg = $tmpl->fetchPage();
$tmplAlt = new \OC_Template('core', 'lostpassword/altnotify');
$msgAlt = $tmplAlt->fetchPage();

try {
$message = $this->mailer->createMessage();
$message->setTo([$email => $userId]);
$message->setSubject($this->l10n->t('%s password changed successfully', [$this->defaults->getName()]));
$message->setPlainBody($msg);
$message->setPlainBody($msgAlt);
$message->setHtmlBody($msg);
$message->setFrom([$this->from => $this->defaults->getName()]);
$this->mailer->send($message);
} catch (\Exception $e) {
Expand Down
5 changes: 5 additions & 0 deletions core/templates/lostpassword/altnotify.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
p($l->t('Password changed successfully'));

print_unescaped("\n\n");
print_unescaped($this->inc('plain.mail.footer'));
34 changes: 32 additions & 2 deletions core/templates/lostpassword/notify.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
<?php
echo $l->t('Password changed successfully');
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td>
<table cellspacing="0" cellpadding="0" border="0" width="600px">
<tr>
<td bgcolor="<?php p($theme->getMailHeaderColor());?>" width="20px">&nbsp;</td>
<td bgcolor="<?php p($theme->getMailHeaderColor());?>">
<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php
p($l->t('Password changed successfully'));
?>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php print_unescaped($this->inc('html.mail.footer')); ?>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</table>
</td></tr>
</table>

5 changes: 4 additions & 1 deletion settings/ChangePassword/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,15 @@ private static function sendNotificationMail($username) {
if ($email !== null && $email !== '') {
$tmpl = new \OC_Template('core', 'lostpassword/notify');
$msg = $tmpl->fetchPage();
$tmplAlt = new \OC_Template('core', 'lostpassword/altnotify');
$msgAlt = $tmplAlt->fetchPage();

try {
$message = $mailer->createMessage();
$message->setTo([$email => $username]);
$message->setSubject($l10n->t('%s password changed successfully', [$defaults->getName()]));
$message->setPlainBody($msg);
$message->setPlainBody($msgAlt);
$message->setHtmlBody($msg);
$message->setFrom([$from => $defaults->getName()]);
$mailer->send($message);
} catch (\Exception $e) {
Expand Down
6 changes: 5 additions & 1 deletion tests/Core/Controller/LostControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,13 @@ public function testSetPasswordSuccessful() {
$message
->expects($this->at(2))
->method('setPlainBody')
->with('Password changed successfully');
->with($this->stringContains('Password changed successfully'));
$message
->expects($this->at(3))
->method('setHtmlBody')
->with($this->stringContains('Password changed successfully'));
$message
->expects($this->at(4))
->method('setFrom')
->with(['lostpassword-noreply@localhost' => null]);
$this->mailer
Expand Down