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,13 @@
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 user_info, ssid, password;
let ssid_match = false;
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,16 +15,15 @@ if (auth === true) {
}
if (wtva.checkPassword(password)) {
if (request_headers.query.ssid) {
var ssid_match = false;
var ssid = request_headers.query.ssid.toLowerCase();
var user_info = wtva.getAccountInfoBySSID(ssid);
ssid = request_headers.query.ssid.toLowerCase();
user_info = wtva.getAccountInfoBySSID(ssid);
if (request_headers.query.confirm_delete) {
user_info = null;
if (ssid == socket.ssid) {
ssid_match = true;
} else {
// delete
var userAccount = wtva.getAccountBySSID(ssid);
const userAccount = wtva.getAccountBySSID(ssid);
userAccount.unregisterBox();
}
}
@@ -101,12 +101,12 @@ wtv-noback-all: wtv-admin:/deleteaccount`;
</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];
}