diff options
Diffstat (limited to 'classes/pref/prefs.php')
-rw-r--r-- | classes/pref/prefs.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index e7e7a365e..2862a84b2 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -122,6 +122,11 @@ class Pref_Prefs extends Handler_Protected { $new_pw = clean($_POST["new_password"]); $con_pw = clean($_POST["confirm_password"]); + if ($old_pw == $new_pw) { + print "ERROR: ".format_error("New password must be different from the old one."); + return; + } + if ($old_pw == "") { print "ERROR: ".format_error("Old password cannot be blank."); return; @@ -194,6 +199,37 @@ class Pref_Prefs extends Handler_Protected { $full_name = clean($_POST["full_name"]); $active_uid = $_SESSION["uid"]; + $sth = $this->pdo->prepare("SELECT email, login, full_name FROM ttrss_users WHERE id = ?"); + $sth->execute([$active_uid]); + + if ($row = $sth->fetch()) { + $old_email = $row["email"]; + + if ($old_email != $email) { + $mailer = new Mailer(); + + require_once "lib/MiniTemplator.class.php"; + + $tpl = new MiniTemplator; + + $tpl->readTemplateFromFile("templates/mail_change_template.txt"); + + $tpl->setVariable('LOGIN', $row["login"]); + $tpl->setVariable('NEWMAIL', $email); + $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); + + $tpl->addBlock('message'); + + $tpl->generateOutputToString($message); + + $mailer->mail(["to_name" => $row["login"], + "to_address" => $row["email"], + "subject" => "[tt-rss] Mail address change notification", + "message" => $message]); + + } + } + $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?, full_name = ? WHERE id = ?"); $sth->execute([$email, $full_name, $active_uid]); @@ -972,6 +1008,31 @@ class Pref_Prefs extends Handler_Protected { if ($authenticator->check_password($_SESSION["uid"], $password)) { + $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?"); + $sth->execute([$_SESSION['uid']]); + + if ($row = $sth->fetch()) { + $mailer = new Mailer(); + + require_once "lib/MiniTemplator.class.php"; + + $tpl = new MiniTemplator; + + $tpl->readTemplateFromFile("templates/otp_disabled_template.txt"); + + $tpl->setVariable('LOGIN', $row["login"]); + $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); + + $tpl->addBlock('message'); + + $tpl->generateOutputToString($message); + + $mailer->mail(["to_name" => $row["login"], + "to_address" => $row["email"], + "subject" => "[tt-rss] OTP change notification", + "message" => $message]); + } + $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = false WHERE id = ?"); $sth->execute([$_SESSION['uid']]); |