Redirect to login page when auto-refreshing a (part of a) page while being logged out (#5951)

This commit is contained in:
mhoogveld
2021-05-28 22:45:11 -06:00
committed by GitHub
parent b94fafbfb9
commit bcf2366dbd
8 changed files with 86 additions and 23 deletions
+14 -5
View File
@@ -244,11 +244,20 @@ unset($refresh_default);
} }
loadXmlHttp.prototype.stateChanged=function () { loadXmlHttp.prototype.stateChanged=function () {
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) var url = new URL(this.xmlHttp.responseURL);
//this.el.innerHTML = this.xmlHttp.responseText; if (/login\.php$/.test(url.pathname)) {
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText; // You are logged out. Stop refresh!
if(document.getElementById('sort')){ refresh_stop();
if(document.getElementById('sort').value != "") url.searchParams.set('path', '<?php echo $_SERVER['REQUEST_URI']; ?>');
window.location.href = url.href;
return;
}
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText;
if (document.getElementById('sort')) {
if (document.getElementById('sort').value != "")
document.getElementById('sort1').value=document.getElementById('sort').value; document.getElementById('sort1').value=document.getElementById('sort').value;
} }
} }
+11 -3
View File
@@ -85,9 +85,17 @@
} }
loadXmlHttp.prototype.stateChanged=function () { loadXmlHttp.prototype.stateChanged=function () {
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) var url = new URL(this.xmlHttp.responseURL);
//this.el.innerHTML = this.xmlHttp.responseText; if (/login\.php$/.test(url.pathname)) {
document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText; // You are logged out. Stop refresh!
url.searchParams.set('path', '<?php echo $_SERVER['REQUEST_URI']; ?>');
window.location.href = url.href;
return;
}
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText;
//link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag //link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag
$('.tr_hover tr,.list tr').each(function(i,e) { $('.tr_hover tr,.list tr').each(function(i,e) {
@@ -84,9 +84,17 @@ function loadXmlHttp(url, id) {
} }
loadXmlHttp.prototype.stateChanged=function () { loadXmlHttp.prototype.stateChanged=function () {
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) var url = new URL(this.xmlHttp.responseURL);
//this.el.innerHTML = this.xmlHttp.responseText; if (/login\.php$/.test(url.pathname)) {
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText; // You are logged out. Stop refresh!
url.searchParams.set('path', '<?php echo $_SERVER['REQUEST_URI']; ?>');
window.location.href = url.href;
return;
}
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText;
//link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag //link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag
$('.tr_hover tr,.list tr').each(function(i,e) { $('.tr_hover tr,.list tr').each(function(i,e) {
+11 -3
View File
@@ -79,9 +79,17 @@ function loadXmlHttp(url, id) {
} }
loadXmlHttp.prototype.stateChanged=function () { loadXmlHttp.prototype.stateChanged=function () {
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) var url = new URL(this.xmlHttp.responseURL);
//this.el.innerHTML = this.xmlHttp.responseText; if (/login\.php$/.test(url.pathname)) {
document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText; // You are logged out. Stop refresh!
url.searchParams.set('path', '<?php echo $_SERVER['REQUEST_URI']; ?>');
window.location.href = url.href;
return;
}
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText;
//link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag //link table rows (except the last - the list_control_icons cell) on a table with a class of 'tr_hover', according to the href attribute of the <tr> tag
$('.tr_hover tr,.list tr').each(function(i,e) { $('.tr_hover tr,.list tr').each(function(i,e) {
@@ -440,6 +440,12 @@ if (!class_exists('destinations')) {
//alert(action); //alert(action);
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
var url = new URL(this.xmlHttp.responseURL);
if (/login\.php$/.test(url.pathname)) {
// You are logged out. Not much we can de here.
return;
}
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
document.getElementById(id).innerHTML = this.responseText; document.getElementById(id).innerHTML = this.responseText;
} }
+11 -3
View File
@@ -93,9 +93,17 @@ function loadXmlHttp(url, id) {
} }
loadXmlHttp.prototype.stateChanged=function () { loadXmlHttp.prototype.stateChanged=function () {
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) var url = new URL(this.xmlHttp.responseURL);
//this.el.innerHTML = this.xmlHttp.responseText; if (/login\.php$/.test(url.pathname)) {
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText; // You are logged out. Stop refresh!
url.searchParams.set('path', '<?php echo $_SERVER['REQUEST_URI']; ?>');
window.location.href = url.href;
return;
}
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText;
} }
var requestTime = function() { var requestTime = function() {
+11 -3
View File
@@ -71,9 +71,17 @@ function loadXmlHttp(url, id) {
} }
loadXmlHttp.prototype.stateChanged=function () { loadXmlHttp.prototype.stateChanged=function () {
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) var url = new URL(this.xmlHttp.responseURL);
//this.el.innerHTML = this.xmlHttp.responseText; if (/login\.php$/.test(url.pathname)) {
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText; // You are logged out. Stop refresh!
url.searchParams.set('path', '<?php echo $_SERVER['REQUEST_URI']; ?>');
window.location.href = url.href;
return;
}
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_reponse').innerHTML = this.xmlHttp.responseText;
} }
var requestTime = function() { var requestTime = function() {
+11 -3
View File
@@ -80,9 +80,17 @@
} }
loadXmlHttp.prototype.stateChanged=function () { loadXmlHttp.prototype.stateChanged=function () {
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) var url = new URL(this.xmlHttp.responseURL);
//this.el.innerHTML = this.xmlHttp.responseText; if (/login\.php$/.test(url.pathname)) {
document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText; // You are logged out. Stop refresh!
url.searchParams.set('path', '<?php echo $_SERVER['REQUEST_URI']; ?>');
window.location.href = url.href;
return;
}
if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href)))
//this.el.innerHTML = this.xmlHttp.responseText;
document.getElementById('ajax_response').innerHTML = this.xmlHttp.responseText;
} }
var requestTime = function() { var requestTime = function() {