authenticate_user always returns true in SINGLE_USER_MODE
This commit is contained in:
parent
3ac2b52019
commit
131b01b336
1 changed files with 28 additions and 19 deletions
|
@ -836,31 +836,40 @@
|
|||
|
||||
function authenticate_user($link, $login, $password) {
|
||||
|
||||
$pwd_hash = 'SHA1:' . sha1($password);
|
||||
if (!SINGLE_USER_MODE) {
|
||||
|
||||
$result = db_query($link, "SELECT id,login,access_level FROM ttrss_users WHERE
|
||||
login = '$login' AND pwd_hash = '$pwd_hash'");
|
||||
$pwd_hash = 'SHA1:' . sha1($password);
|
||||
|
||||
if (db_num_rows($result) == 1) {
|
||||
$_SESSION["uid"] = db_fetch_result($result, 0, "id");
|
||||
$_SESSION["name"] = db_fetch_result($result, 0, "login");
|
||||
$_SESSION["access_level"] = db_fetch_result($result, 0, "access_level");
|
||||
$result = db_query($link, "SELECT id,login,access_level FROM ttrss_users WHERE
|
||||
login = '$login' AND pwd_hash = '$pwd_hash'");
|
||||
|
||||
db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
|
||||
$_SESSION["uid"]);
|
||||
if (db_num_rows($result) == 1) {
|
||||
$_SESSION["uid"] = db_fetch_result($result, 0, "id");
|
||||
$_SESSION["name"] = db_fetch_result($result, 0, "login");
|
||||
$_SESSION["access_level"] = db_fetch_result($result, 0, "access_level");
|
||||
|
||||
$user_theme = get_user_theme_path($link);
|
||||
db_query($link, "UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
|
||||
$_SESSION["uid"]);
|
||||
|
||||
$_SESSION["theme"] = $user_theme;
|
||||
$_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
|
||||
$user_theme = get_user_theme_path($link);
|
||||
|
||||
initialize_user_prefs($link, $_SESSION["uid"]);
|
||||
$_SESSION["theme"] = $user_theme;
|
||||
$_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"];
|
||||
|
||||
initialize_user_prefs($link, $_SESSION["uid"]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
$_SESSION["uid"] = 1;
|
||||
$_SESSION["name"] = "admin";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function make_password($length = 8) {
|
||||
|
|
Loading…
Reference in a new issue