Notify user if email address is changed

This commit is contained in:
Hillel Coren 2018-02-20 10:52:53 +02:00
parent a9faea4054
commit e423475195
4 changed files with 30 additions and 3 deletions

View File

@ -46,6 +46,8 @@ class HandleUserSettingsChanged
if ($event->user && $event->user->isEmailBeingChanged()) { if ($event->user && $event->user->isEmailBeingChanged()) {
$this->userMailer->sendConfirmation($event->user); $this->userMailer->sendConfirmation($event->user);
$this->userMailer->sendEmailChanged($event->user);
Session::flash('warning', trans('texts.verify_email')); Session::flash('warning', trans('texts.verify_email'));
} }
} }

View File

@ -319,9 +319,7 @@ class User extends Authenticatable
*/ */
public function isEmailBeingChanged() public function isEmailBeingChanged()
{ {
return Utils::isNinjaProd() return Utils::isNinjaProd() && $this->email != $this->getOriginal('email');
&& $this->email != $this->getOriginal('email')
&& $this->getOriginal('confirmed');
} }
/** /**

View File

@ -38,6 +38,31 @@ class UserMailer extends Mailer
$this->sendTo($user->email, $fromEmail, $fromName, $subject, $view, $data); $this->sendTo($user->email, $fromEmail, $fromName, $subject, $view, $data);
} }
/**
* @param User $user
* @param User|null $invitor
*/
public function sendEmailChanged(User $user)
{
$oldEmail = $user->getOriginal('email');
$newEmail = $user->email;
if (! $oldEmail || ! $newEmail) {
return;
}
$view = 'user_message';
$subject = trans('texts.email_address_changed');
$data = [
'user' => $user,
'userName' => $user->getDisplayName(),
'primaryMessage' => trans('texts.email_address_changed_message', ['old_email' => $oldEmail, 'new_email' => $newEmail]),
];
$this->sendTo($oldEmail, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
/** /**
* @param User $user * @param User $user
* @param Invoice $invoice * @param Invoice $invoice

View File

@ -2742,6 +2742,8 @@ $LANG = array(
'change_requires_purge' => 'Changing this setting requires :link the account data.', 'change_requires_purge' => 'Changing this setting requires :link the account data.',
'purging' => 'purging', 'purging' => 'purging',
'warning_local_refund' => 'The refund will be recorded in the app but will NOT be processed by the payment gateway.', 'warning_local_refund' => 'The refund will be recorded in the app but will NOT be processed by the payment gateway.',
'email_address_changed' => 'Email address has been changed',
'email_address_changed_message' => 'The email address for your account has been changed from :old_email to :new_email.',
); );