From 5b3bde12791ebb704bd713f815a8c25129ef4772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Ho=CC=88=C3=9Fl?= Date: Sat, 23 Nov 2024 13:44:30 +0100 Subject: [PATCH] Allow using the name in password-recovery e-mail --- models/db/User.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/models/db/User.php b/models/db/User.php index b3bbe9550..9e3b35484 100644 --- a/models/db/User.php +++ b/models/db/User.php @@ -753,9 +753,13 @@ public function sendRecoveryMail(): void $subject = \Yii::t('user', 'recover_mail_title'); $url = UrlHelper::createUrl(['user/recovery', 'email' => $this->email, 'code' => $recoveryToken]); $url = UrlHelper::absolutizeLink($url); - $text = \Yii::t('user', 'recover_mail_body'); - $replaces = ['%URL%' => $url, '%CODE%' => $recoveryToken]; - MailTools::sendWithLog($type, null, $this->email, $this->id, $subject, $text, '', $replaces); + $text = str_replace( + ['%NAME_GIVEN%', '%NAME_FAMILY%'], + [$this->getGivenNameWithFallback(), $this->getFamilyNameWithFallback()], + \Yii::t('user', 'recover_mail_body') + ); + $noLogReplaces = ['%URL%' => $url, '%CODE%' => $recoveryToken]; + MailTools::sendWithLog($type, null, $this->email, $this->id, $subject, $text, '', $noLogReplaces); } /**