Created
March 11, 2019 06:34
-
-
Save seanvree/3f7241de25b78c93f2c970f582356b3e to your computer and use it in GitHub Desktop.
authcheck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkLogin() { | |
console.log('Logarr auth: ENABLED | Checking login status (checkLogin)'); | |
$.ajax({ | |
type: "GET", | |
url: "assets/php/login-status.php", | |
// data: info, | |
success: function (data) { | |
if (data === "true") { | |
// User is logged IN: | |
console.log('Logarr user is logged IN (checkLogin)'); | |
} else { | |
// User is logged OUT: | |
console.log('Logarr user is logged OUT (checkLogin)'); | |
logouttoast(); | |
//If user user logs out, refresh index page to envoke authentication page after 3s: | |
setTimeout(function () { | |
window.location.href = "index.php"; | |
}, 3000); | |
} | |
}, | |
error: function () { | |
// error | |
console.log('ERROR: An error occurred while checking login status (checkLogin)'); | |
} | |
}); | |
//check login status every 10s: | |
//setInterval(checkLogin, 3000); | |
} | |
function checkLoginauto() { | |
console.log('Logarr is checking auth settings (checkLoginauto)'); | |
$.ajax({ | |
type: "GET", | |
url: "assets/php/auth-config.php", | |
// data: info, | |
success: function (data) { | |
if (data === "true") { | |
// Logger auth enabled: | |
console.log('Logger auth: ENABLED (checkLoginauto)'); | |
// setInterval(function () { | |
// checkLogin(); | |
// }, 5000); | |
} else { | |
// Logger auth disabled | |
console.log('Logger auth: DISABLED (checkLoginauto)'); | |
//logouttoast(); | |
// If user user logs out, refresh index page to envoke authentication page after 3s: | |
// setTimeout(function () { | |
// window.location.href = "index.php"; | |
// }, 3000); | |
} | |
}, | |
error: function () { | |
// error | |
console.log('ERROR: An error occurred while checking login status (checkLoginauto)'); | |
} | |
}); | |
//check login status every 10s: | |
// setInterval(function () { | |
//checkLoginauto(); | |
// }, 15000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment