]> git.wh0rd.org Git - tt-rss.git/commitdiff
login system fixes
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 1 Mar 2007 12:09:05 +0000 (13:09 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 1 Mar 2007 12:09:05 +0000 (13:09 +0100)
functions.js
functions.php
sessions.php

index f4c8ee1c18fd87fa6665f4a73e755bfb52678267..35b1e13190553ed86f56785b55b4886fae11cac1 100644 (file)
@@ -56,7 +56,7 @@ function logout_callback() {
        var container = document.getElementById('notify');
        if (xmlhttp.readyState == 4) {
                try {
-                       window.location.reload(true);
+                       window.location.href = "tt-rss.php";
                } catch (e) {
                        exception_error("logout_callback", e);
                }
index 17069635279130b29d6d318ecde1d012fcbbf0c2..59086506af41ef06e475f8f8087c88536c624042 100644 (file)
                                }
                        }
                }
+
+               if ($_SESSION["cookie_lifetime"] && $_SESSION["uid"]) {
+
+#                      print time() . " vs " .  $_SESSION["cookie_lifetime"];
+
+                       if (time() > $_SESSION["cookie_lifetime"]) {
+                               return false;
+                       }
+               }
                return true;
        }
 
                        if ($login_action == "do_login") {
                                $login = $_POST["login"];
                                $password = $_POST["password"];
+                               $remember_me = $_POST["remember_me"];
 
                                if (authenticate_user($link, $login, $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;
                                }
                        }
                                render_login_form($link);
                                exit;
                        }
+
                } else {
                        return authenticate_user($link, "admin", null);
                }
index aab945d4dd0faedf56f80e8d8a7bb683276a5bba..c2854e04a4d28295ea3a0ef2120c22a93914c51f 100644 (file)
                db_query($session_connection, $query);
        }
 
-//     session_set_cookie_params(SESSION_COOKIE_LIFETIME);
-
        if (DATABASE_BACKED_SESSIONS) {
                session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
        }
-       
+
+       session_set_cookie_params(SESSION_COOKIE_LIFETIME_REMEMBER);
+
        session_start();
 ?>