|
|
@ -271,18 +271,16 @@ class Pref_Users extends Handler_Protected {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static function resetUserPassword($uid, $show_password) {
|
|
|
|
static function resetUserPassword($uid, $format_output = false) {
|
|
|
|
|
|
|
|
|
|
|
|
$pdo = Db::pdo();
|
|
|
|
$pdo = Db::pdo();
|
|
|
|
|
|
|
|
|
|
|
|
$sth = $pdo->prepare("SELECT login, email
|
|
|
|
$sth = $pdo->prepare("SELECT login FROM ttrss_users WHERE id = ?");
|
|
|
|
FROM ttrss_users WHERE id = ?");
|
|
|
|
|
|
|
|
$sth->execute([$uid]);
|
|
|
|
$sth->execute([$uid]);
|
|
|
|
|
|
|
|
|
|
|
|
if ($row = $sth->fetch()) {
|
|
|
|
if ($row = $sth->fetch()) {
|
|
|
|
|
|
|
|
|
|
|
|
$login = $row["login"];
|
|
|
|
$login = $row["login"];
|
|
|
|
$email = $row["email"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
|
|
|
|
$new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
|
|
|
|
$tmp_user_pwd = make_password(8);
|
|
|
|
$tmp_user_pwd = make_password(8);
|
|
|
@ -294,44 +292,19 @@ class Pref_Users extends Handler_Protected {
|
|
|
|
WHERE id = ?");
|
|
|
|
WHERE id = ?");
|
|
|
|
$sth->execute([$pwd_hash, $new_salt, $uid]);
|
|
|
|
$sth->execute([$pwd_hash, $new_salt, $uid]);
|
|
|
|
|
|
|
|
|
|
|
|
if ($show_password) {
|
|
|
|
$message = T_sprintf("Changed password of user %s to %s", "<strong>$login</strong>", "<strong>$tmp_user_pwd</strong>");
|
|
|
|
print_notice(T_sprintf("Changed password of user %s to %s", $login, $tmp_user_pwd));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
print_notice(T_sprintf("Sending new password of user %s to %s", $login, $email));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($email) {
|
|
|
|
|
|
|
|
require_once "lib/MiniTemplator.class.php";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tpl = new MiniTemplator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tpl->readTemplateFromFile("templates/resetpass_template.txt");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tpl->setVariable('LOGIN', $login);
|
|
|
|
|
|
|
|
$tpl->setVariable('NEWPASS', $tmp_user_pwd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tpl->addBlock('message');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$message = "";
|
|
|
|
if ($format_output)
|
|
|
|
|
|
|
|
print_notice($message);
|
|
|
|
$tpl->generateOutputToString($message);
|
|
|
|
else
|
|
|
|
|
|
|
|
print $message;
|
|
|
|
$mailer = new Mailer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rc = $mailer->mail(["to_name" => $login,
|
|
|
|
|
|
|
|
"to_address" => $email,
|
|
|
|
|
|
|
|
"subject" => __("[tt-rss] Password change notification"),
|
|
|
|
|
|
|
|
"message" => $message]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$rc) print_error($mailer->error());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function resetPass() {
|
|
|
|
function resetPass() {
|
|
|
|
$uid = clean($_REQUEST["id"]);
|
|
|
|
$uid = clean($_REQUEST["id"]);
|
|
|
|
Pref_Users::resetUserPassword($uid, true);
|
|
|
|
Pref_Users::resetUserPassword($uid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function index() {
|
|
|
|
function index() {
|
|
|
|