Skip to content

Commit

Permalink
add cookie sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
jxmx committed Apr 27, 2022
1 parent d8d41b4 commit bd5a43b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let config = {
// statuses and counters
var qsinceload = 0;
var sectionsloaded = false;
var stationcookieexists = false;

// load configuration from JSON files
function getConfig(configType){
Expand Down Expand Up @@ -93,6 +94,7 @@ window.addEventListener("load", function(){
setGeneralConfig();
updateLogTime();
setInterval(updateLogTime,1000);
setInterval(testCookieExists,1000);
});

//
Expand Down Expand Up @@ -500,8 +502,6 @@ $('#mode').on('input', function() {


// Read the data from the cookie and set it on page load


// Generic set method
function setCookie(cname, cvalue, exdays) {
var d = new Date();
Expand Down Expand Up @@ -533,6 +533,7 @@ function saveStationData() {
setCookie("operator", document.getElementById("operator").value, 30);
setCookie("band", document.getElementById("band").value, 30);
setCookie("mode", document.getElementById("mode").value, 30);
stationcookieexists = true;
} else {
alertStatusMsg("Station information not complete");
}
Expand All @@ -558,4 +559,17 @@ function setStationDataFromCookie() {
document.getElementById("mode").value = mode;
submitOkMode = true;
}

if( submitOkOperCall && submitOkBand && submitOkMode ){
stationcookieexists = true;
}
}

function testCookieExists(){
if( stationcookieexists ){
if( getCookie("operator") === "" || getCookie("band") === "" || getCookie("mode") === "" ){
alert("SYSTEM ERROR: Configuration Cookie Vanished!\nAre you using https:// ?\nStop logging and talk to the person who runs this logging instance!");
stationcookieexists = false;
}
}
}

0 comments on commit bd5a43b

Please sign in to comment.