Merge pull request #5521 from nextcloud/backport-5508-no-acitivity-before-login

[stable12] Don't create activities for email and password change before login
This commit is contained in:
Morris Jobke 2017-06-23 11:23:50 -05:00 committed by GitHub
commit cb9a6a81a4
1 changed files with 6 additions and 3 deletions

View File

@ -78,7 +78,8 @@ class Hooks {
public function onChangePassword($uid) {
$user = $this->userManager->get($uid);
if (!$user instanceof IUser || $user->getEMailAddress() === null) {
if (!$user instanceof IUser || $user->getLastLogin() === 0) {
// User didn't login, so don't create activities and emails.
return;
}
@ -141,8 +142,10 @@ class Hooks {
*/
public function onChangeEmail(IUser $user, $oldMailAddress) {
if ($oldMailAddress === $user->getEMailAddress()) {
// Email didn't really change, so don't create activities and emails
if ($oldMailAddress === $user->getEMailAddress() ||
$user->getLastLogin() === 0) {
// Email didn't really change or user didn't login,
// so don't create activities and emails.
return;
}