-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Send email notification when user email changes. #14136
Changes from 4 commits
3f1666c
980bba5
ce0d380
3946637
8d7f80c
a8e5cb6
41c371b
9dbc53d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<p>{{ 'General_HelloUser'|translate('<strong>' ~ accountName ~ '</strong>')|raw }}</p> | ||
|
||
<p>{{ 'UsersManager_EmailChangedEmail1'|translate('<strong>' ~ newEmail ~ '</strong>')|raw }}.</p> | ||
|
||
{% set deviceDescription %}{{ deviceName }}{% if deviceBrand is not empty or deviceModel is not empty %} ({% if deviceBrand is not empty %}{{ deviceBrand }}{% endif %}{% if deviceModel is not empty %} {{ deviceModel }}{% endif %}){% endif %}{% endset %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the device name always set? Looking at the code it may be empty but probably isn't really often the case. May not be too useful though to show whether it was updated from desktop or mobile if no device was detected. Not too important though and fine to leave it just like that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reckon there can be various cases where user agent may not be set when details are updated through the API. Therefore device name may be empty on occasion |
||
<p>{{ 'UsersManager_EmailChangedEmail2'|translate(deviceDescription, ipAddress) }} {{ 'UsersManager_IfThisWasYouIgnoreIfNot'|translate }}</p> | ||
|
||
<p>{{ 'General_ThankYouForUsingMatomo'|translate }}! | ||
<br/>The Matomo team</p> | ||
diosmosis marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<p>{{ 'General_HelloUser'|translate('<strong>' ~ accountName ~ '</strong>')|raw }}</p> | ||
|
||
{% set deviceDescription %}{{ deviceName }}{% if deviceBrand is not empty or deviceModel is not empty %} ({% if deviceBrand is not empty %}{{ deviceBrand }}{% endif %}{% if deviceModel is not empty %} {{ deviceModel }}{% endif %}){% endif %}{% endset %} | ||
<p>{{ 'UsersManager_PasswordChangedEmail'|translate(deviceDescription, ipAddress) }}</p> | ||
|
||
<p>{{ 'UsersManager_IfThisWasYouIgnoreIfNot'|translate }}</p> | ||
|
||
<p>{{ 'General_ThankYouForUsingMatomo'|translate }}! | ||
<br/>The Matomo team</p> | ||
diosmosis marked this conversation as resolved.
Show resolved
Hide resolved
|
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() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we maybe mostly reuse the same code for
sendEmailChangedEmail
andsendPasswordChangedEmail
and also it's templates and only have different mail subject and also different leading sentence in the email? not too important though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about it, but since there were just two emails, and the code isn't really complicated (just setting things on the view & Mail instance), it didn't seem that important. Maybe if there are more changes to a user that we should notify them about?