-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send email notification when user email changes. (#14136)
* Send email notification when user email changes. * Forgot to add file. * Apply pr fixes + send email for password changes too. * Add quick test for new emails. * Translate text * Refactor according to review. * ucfirst device name * Fixing integration test
- Loading branch information
Showing
6 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<p>{{ 'General_HelloUser'|translate('<strong>' ~ accountName ~ '</strong>')|raw }}</p> | ||
|
||
{% if type == 'email' %} | ||
<p>{{ 'UsersManager_EmailChangedEmail1'|translate('<strong>' ~ newEmail ~ '</strong>')|raw }}.</p> | ||
|
||
<p>{{ 'UsersManager_EmailChangedEmail2'|translate(deviceDescription, ipAddress) }} {{ 'UsersManager_IfThisWasYouIgnoreIfNot'|translate }}</p> | ||
{% elseif type == 'password' %} | ||
<p>{{ 'UsersManager_PasswordChangedEmail'|translate(deviceDescription, ipAddress) }}</p> | ||
|
||
<p>{{ 'UsersManager_IfThisWasYouIgnoreIfNot'|translate }}</p> | ||
{% endif %} | ||
|
||
<p>{{ 'General_ThankYouForUsingMatomo'|translate }}! | ||
<br/>{{ 'General_TheMatomoTeam'|translate }}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
use Piwik\Access\Role\Write; | ||
use Piwik\Auth\Password; | ||
use Piwik\Container\StaticContainer; | ||
use Piwik\Mail; | ||
use Piwik\Option; | ||
use Piwik\Piwik; | ||
use Piwik\Plugins\SitesManager\API as SitesManagerAPI; | ||
|
@@ -293,6 +294,11 @@ public function test_setUserPreference_throws_whenPreferenceNameContainsUndersco | |
|
||
public function test_updateUser() | ||
{ | ||
$capturedMails = []; | ||
Piwik::addAction('Mail.send', function (Mail $mail) use (&$capturedMails) { | ||
$capturedMails[] = $mail; | ||
}); | ||
|
||
$identity = FakeAccess::$identity; | ||
FakeAccess::$identity = $this->login; // ensure password will be checked against this user | ||
$this->api->updateUser($this->login, 'newPassword', '[email protected]', 'newAlias', false, $this->password); | ||
|
@@ -307,6 +313,13 @@ public function test_updateUser() | |
$passwordHelper = new Password(); | ||
|
||
$this->assertTrue($passwordHelper->verify(UsersManager::getPasswordHash('newPassword'), $user['password'])); | ||
|
||
$subjects = array_map(function (Mail $mail) { return $mail->getSubject(); }, $capturedMails); | ||
$this->assertEquals([ | ||
'UsersManager_EmailChangeNotificationSubject', // sent twice to old email and new | ||
'UsersManager_EmailChangeNotificationSubject', | ||
'UsersManager_PasswordChangeNotificationSubject', | ||
], $subjects); | ||
} | ||
|
||
public function test_updateUser_doesNotChangePasswordIfFalsey() | ||
|