prefs: allow setting email if it was previously blank

This commit is contained in:
Andrew Dolgov 2021-03-17 19:50:04 +03:00
parent ce9955c6ff
commit 43ea36d030
1 changed files with 15 additions and 15 deletions

View File

@ -231,29 +231,29 @@ class Pref_Prefs extends Handler_Protected {
if ($user) {
$user->full_name = clean($_POST['full_name']);
if ($user->email != $new_email)
if ($user->email != $new_email) {
Logger::log(E_USER_NOTICE, "Email address of user ".$user->login." has been changed to ${new_email}.");
if ($user->email && $user->email != $new_email) {
if ($user->email) {
$mailer = new Mailer();
$mailer = new Mailer();
$tpl = new Templator();
$tpl = new Templator();
$tpl->readTemplateFromFile("mail_change_template.txt");
$tpl->readTemplateFromFile("mail_change_template.txt");
$tpl->setVariable('LOGIN', $user->login);
$tpl->setVariable('NEWMAIL', $new_email);
$tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH));
$tpl->setVariable('LOGIN', $user->login);
$tpl->setVariable('NEWMAIL', $new_email);
$tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH));
$tpl->addBlock('message');
$tpl->addBlock('message');
$tpl->generateOutputToString($message);
$tpl->generateOutputToString($message);
$mailer->mail(["to_name" => $user->login,
"to_address" => $user->email,
"subject" => "[tt-rss] Email address change notification",
"message" => $message]);
$mailer->mail(["to_name" => $user->login,
"to_address" => $user->email,
"subject" => "[tt-rss] Email address change notification",
"message" => $message]);
}
$user->email = $new_email;
}