auth: forcefully logout if an ajax call returns 401

This *should* fix fail2ban banning overzealous groups of ajax queries by fully logging out immediately upon the first bad request.
This commit is contained in:
liaralabs 2023-03-28 17:50:11 -07:00 committed by GitHub
parent 0dc9dc6fa4
commit a5335490b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -275,8 +275,7 @@ function appstatus(){
$.get("{{ url_for('app_status') }}", function(data, xhr){
if(xhr.status==401)
{
clearTimeout(timer);
return
window.location.href = "{{ url_for('logout') }}";
}
for (var apps in data) {
var name = data[apps]["name"];
@ -303,8 +302,7 @@ appstatus();
$.get('{{ url_for('loadavg') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
window.location.href = "{{ url_for('logout') }}";
}
$("#load1m").html(data['1m']);
$("#load5m").html(data['5m']);
@ -326,8 +324,7 @@ appstatus();
$.get('{{ url_for('disk_free') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
window.location.href = "{{ url_for('logout') }}";
}
for (var mount in data) {
var percent = Math.trunc(data[mount]['perutil']);
@ -354,8 +351,7 @@ appstatus();
$.get('{{ url_for('ram_stats') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
window.location.href = "{{ url_for('logout') }}";
}
var percent = Math.trunc(data['perutil']);
$("#ramfree").html(data['ramfree']);
@ -381,8 +377,7 @@ appstatus();
$.get('{{ url_for('vnstat') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
window.location.href = "{{ url_for('logout') }}";
}
$("#top10").html(data);
setTimeout(function(){vnstat_top10()}, 600000);
@ -443,8 +438,7 @@ appstatus();
$.get('{{ url_for('network_quota') }}', function(data, xhr) {
if(xhr.status==401)
{
clearTimeout(timer);
return
window.location.href = "{{ url_for('logout') }}";
}
var percent = Math.trunc(data['perutil']);
$("#netfree").html(data['netfree']);