login system fixes

This commit is contained in:
Andrew Dolgov 2007-03-01 13:09:05 +01:00
parent 64f6db9051
commit d620cfe70a
3 changed files with 29 additions and 4 deletions

View File

@ -56,7 +56,7 @@ function logout_callback() {
var container = document.getElementById('notify'); var container = document.getElementById('notify');
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
try { try {
window.location.reload(true); window.location.href = "tt-rss.php";
} catch (e) { } catch (e) {
exception_error("logout_callback", e); exception_error("logout_callback", e);
} }

View File

@ -1167,6 +1167,15 @@
} }
} }
} }
if ($_SESSION["cookie_lifetime"] && $_SESSION["uid"]) {
# print time() . " vs " . $_SESSION["cookie_lifetime"];
if (time() > $_SESSION["cookie_lifetime"]) {
return false;
}
}
return true; return true;
} }
@ -1193,9 +1202,24 @@
if ($login_action == "do_login") { if ($login_action == "do_login") {
$login = $_POST["login"]; $login = $_POST["login"];
$password = $_POST["password"]; $password = $_POST["password"];
$remember_me = $_POST["remember_me"];
if (authenticate_user($link, $login, $password)) { if (authenticate_user($link, $login, $password)) {
$_POST["password"] = ""; $_POST["password"] = "";
if ($remember_me) {
$_SESSION["cookie_lifetime"] = time() +
SESSION_COOKIE_LIFETIME_REMEMBER;
} else {
$_SESSION["cookie_lifetime"] = time() + SESSION_COOKIE_LIFETIME;
}
setcookie("ttrss_cltime", $_SESSION["cookie_lifetime"],
$_SESSION["cookie_lifetime"]);
header("Location: " . $_SERVER["REQUEST_URI"]);
exit;
return; return;
} }
} }
@ -1204,6 +1228,7 @@
render_login_form($link); render_login_form($link);
exit; exit;
} }
} else { } else {
return authenticate_user($link, "admin", null); return authenticate_user($link, "admin", null);
} }

View File

@ -91,11 +91,11 @@
db_query($session_connection, $query); db_query($session_connection, $query);
} }
// session_set_cookie_params(SESSION_COOKIE_LIFETIME);
if (DATABASE_BACKED_SESSIONS) { if (DATABASE_BACKED_SESSIONS) {
session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
} }
session_set_cookie_params(SESSION_COOKIE_LIFETIME_REMEMBER);
session_start(); session_start();
?> ?>