fix/optimize wtv-admin
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
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;
|
||||
let password = null;
|
||||
let show_cannot_modify_self = false;
|
||||
let show_cannot_remove_primary = false;
|
||||
let result = false;
|
||||
const show_box_was_unregistered = 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,10 +19,8 @@ if (auth === true) {
|
||||
}
|
||||
if (wtva.checkPassword(password)) {
|
||||
if (request_headers.query.username) {
|
||||
var show_cannot_modify_self = false;
|
||||
var show_cannot_remove_primary = false;
|
||||
var show_box_was_unregistered = false;
|
||||
var user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
||||
|
||||
user_info = wtva.getAccountInfo(request_headers.query.username.toLowerCase()); // username search
|
||||
if (user_info) {
|
||||
if (user_info.ssid == socket.ssid) {
|
||||
show_cannot_modify_self = true;
|
||||
@@ -25,13 +28,13 @@ if (auth === true) {
|
||||
if (request_headers.query.confirm_delete) {
|
||||
if (!show_cannot_modify_self) {
|
||||
// delete
|
||||
var userAccount = wtva.getAccountBySSID(user_info.ssid);
|
||||
const userAccount = wtva.getAccountBySSID(user_info.ssid);
|
||||
userAccount.switchUserID(0, false, false);
|
||||
var userCount = Object.keys(user_info.account_users).length;
|
||||
const userCount = Object.keys(user_info.account_users).length;
|
||||
if (user_info.user_id === 0) {
|
||||
show_cannot_remove_primary = true;
|
||||
} else {
|
||||
var result = userAccount.removeUser(user_info.user_id);
|
||||
result = userAccount.removeUser(user_info.user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,12 +110,12 @@ wtv-noback-all: wtv-admin:/deleteuser`;
|
||||
</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];
|
||||
}
|
||||
Reference in New Issue
Block a user