fix/optimize wtv-admin

This commit is contained in:
zefie
2025-08-12 18:28:56 -04:00
parent b9d64de79e
commit d5c04688e9
14 changed files with 159 additions and 148 deletions

View File

@@ -1,12 +1,12 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var WTVAdmin = require(classPath + "/WTVAdmin.js");
var wtva = new WTVAdmin(minisrv_config, session_data, service_name);
var auth = wtva.isAuthorized();
const WTVAdmin = require(classPath + "/WTVAdmin.js");
const wtva = new WTVAdmin(minisrv_config, session_data, service_name);
const auth = wtva.isAuthorized();
if (auth === true) {
var password = null;
let result, ssid, password;
if (request_headers.Authorization) {
var authheader = request_headers.Authorization.split(' ');
const authheader = request_headers.Authorization.split(' ');
if (authheader[0] == "Basic") {
password = Buffer.from(authheader[1], 'base64').toString();
if (password) password = password.split(':')[1];
@@ -14,8 +14,8 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
if (request_headers.query.ssid) {
var ssid = request_headers.query.ssid.toLowerCase();
var result = wtva.banSSID(ssid, socket.ssid);
ssid = request_headers.query.ssid.toLowerCase();
result = wtva.banSSID(ssid, socket.ssid);
}
headers = `200 OK
Content-Type: text/html
@@ -69,12 +69,12 @@ wtv-expire-all: wtv-admin:/ban`;
</html>
`;
} else {
var errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
const errpage = wtvshared.doErrorPage(401, "Please enter the administration password, you can leave the username blank.");
headers = errpage[0];
data = errpage[1];
}
} else {
var errpage = wtvshared.doErrorPage(403, auth);
const errpage = wtvshared.doErrorPage(403, auth);
headers = errpage[0];
data = errpage[1];
}