mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-01-06 08:45:32 +00:00
main.js: implemented feature to store token in local storage to prevent logging out on page refresh.
This commit is contained in:
@@ -24,6 +24,9 @@ var reverseProxyDetected = false;
|
||||
function showPageLogin() {
|
||||
hideAlert();
|
||||
|
||||
localStorage.removeItem("username");
|
||||
localStorage.removeItem("token");
|
||||
|
||||
$("#pageMain").hide();
|
||||
$("#mnuUser").hide();
|
||||
|
||||
@@ -493,8 +496,18 @@ $(function () {
|
||||
|
||||
$("#lblDoHHost").text(window.location.hostname + ":8053");
|
||||
|
||||
showPageLogin();
|
||||
login("admin", "admin");
|
||||
token = localStorage.getItem("token");
|
||||
if (token == null) {
|
||||
showPageLogin();
|
||||
login("admin", "admin");
|
||||
}
|
||||
else {
|
||||
username = localStorage.getItem("username");
|
||||
if (username == null)
|
||||
username = "admin";
|
||||
|
||||
showPageMain(username);
|
||||
}
|
||||
});
|
||||
|
||||
function login(username, password) {
|
||||
@@ -527,6 +540,9 @@ function login(username, password) {
|
||||
success: function (responseJSON) {
|
||||
token = responseJSON.token;
|
||||
|
||||
localStorage.setItem("username", username);
|
||||
localStorage.setItem("token", token);
|
||||
|
||||
showPageMain(username);
|
||||
|
||||
if ((username === "admin") && (password === "admin")) {
|
||||
|
||||
Reference in New Issue
Block a user