improve session expiry handling (redirect back to login form on rpc error code 6)

This commit is contained in:
Andrew Dolgov 2006-11-09 11:00:24 +01:00
parent 2e4afda7bf
commit 4724a093a8
3 changed files with 40 additions and 11 deletions

View File

@ -779,6 +779,11 @@ function hideOrShowFeedsCategory(doc, node, hide, cat_node) {
var cat_unread = 0; var cat_unread = 0;
if (!node) {
debug("hideOrShowFeeds: passed node is null, aborting");
return;
}
if (node.hasChildNodes() && node.firstChild.nextSibling != false) { if (node.hasChildNodes() && node.firstChild.nextSibling != false) {
for (i = 0; i < node.childNodes.length; i++) { for (i = 0; i < node.childNodes.length; i++) {
if (node.childNodes[i].nodeName != "LI") { continue; } if (node.childNodes[i].nodeName != "LI") { continue; }
@ -1394,12 +1399,18 @@ function storeInitParams(params, is_client) {
function fatalError(code, message) { function fatalError(code, message) {
try { try {
if (code != 6) {
var fe = document.getElementById("fatal_error"); var fe = document.getElementById("fatal_error");
var fc = document.getElementById("fatal_error_msg"); var fc = document.getElementById("fatal_error_msg");
fc.innerHTML = "Code " + code + ": " + message; fc.innerHTML = "Code " + code + ": " + message;
fe.style.display = "block"; fe.style.display = "block";
} else {
window.location.href = "login.php?rt=none";
}
} catch (e) { } catch (e) {
exception_error("fatalError", e); exception_error("fatalError", e);

View File

@ -9,6 +9,7 @@
$error_msg = ""; $error_msg = "";
$url_path = get_script_urlpath(); $url_path = get_script_urlpath();
$return_to = $_REQUEST["rt"];
if (ENABLE_LOGIN_SSL) { if (ENABLE_LOGIN_SSL) {
$redirect_base = "https://" . $_SERVER["SERVER_NAME"] . $url_path; $redirect_base = "https://" . $_SERVER["SERVER_NAME"] . $url_path;
@ -16,7 +17,7 @@
$redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path; $redirect_base = "http://" . $_SERVER["SERVER_NAME"] . $url_path;
} }
if (SINGLE_USER_MODE) { if (SINGLE_USER_MODE && $return_to != "none") {
header("Location: $redirect_base/tt-rss.php"); header("Location: $redirect_base/tt-rss.php");
exit; exit;
} }
@ -25,10 +26,9 @@
$login = $_POST["login"]; $login = $_POST["login"];
$password = $_POST["password"]; $password = $_POST["password"];
$return_to = $_POST["rt"];
$action = $_POST["action"]; $action = $_POST["action"];
if ($_COOKIE[get_session_cookie_name()]) { if ($_COOKIE[get_session_cookie_name()] && $return_to != "none") {
require_once "sessions.php"; require_once "sessions.php";
if ($_SESSION["uid"]) { if ($_SESSION["uid"]) {
initialize_user_prefs($link, $_SESSION["uid"]); initialize_user_prefs($link, $_SESSION["uid"]);
@ -129,7 +129,8 @@ window.onload = init;
<tr><td colspan="2" align="right" class="innerLoginCell"> <tr><td colspan="2" align="right" class="innerLoginCell">
<input type="submit" class="button" value="Login"> <input type="submit" class="button" value="Login">
<input type="hidden" name="action" value="login"> <input type="hidden" name="action" value="login">
<input type="hidden" name="rt" value="<?php echo $_GET['rt'] ?>"> <input type="hidden" name="rt"
value="<?php if ($return_to != 'none') { echo $return_to; } ?>">
</td></tr> </td></tr>
</table> </table>
</td> </td>

View File

@ -73,10 +73,22 @@ function refetch_callback() {
return; return;
} }
var error_code = reply.getAttribute("error-code"); var error_code = false;
var error_msg = false;
if (reply.firstChild) {
error_code = reply.firstChild.getAttribute("error-code");
error_msg = reply.firstChild.getAttribute("error-msg");
}
if (!error_code) {
error_code = reply.getAttribute("error-code");
error_msg = reply.getAttribute("error-msg");
}
if (error_code && error_code != 0) { if (error_code && error_code != 0) {
return fatalError(error_code, reply.getAttribute("error-msg")); debug("refetch_callback: got error code " + error_code);
return fatalError(error_code, error_msg);
} }
var counters = reply.firstChild; var counters = reply.firstChild;
@ -535,6 +547,11 @@ function toggleDispRead() {
} }
function parse_runtime_info(elem) { function parse_runtime_info(elem) {
if (!elem) {
debug("parse_runtime_info: elem is null, aborting");
return;
}
var param = elem.firstChild; var param = elem.firstChild;
debug("parse_runtime_info: " + param); debug("parse_runtime_info: " + param);