diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-setup/accounts.js b/zefie_wtvp_minisrv/ServiceVault/wtv-setup/accounts.js
index 0ca7ea10..27e0446c 100644
--- a/zefie_wtvp_minisrv/ServiceVault/wtv-setup/accounts.js
+++ b/zefie_wtvp_minisrv/ServiceVault/wtv-setup/accounts.js
@@ -8,6 +8,7 @@ if (ssid_sessions[socket.ssid].user_id != 0) {
} else {
headers = `200 OK
Connection: Keep-Alive
+wtv-expire-all: wtv-setup:/accounts
Content-Type: text/html`
data = `
@@ -112,14 +113,14 @@ Subscriber:
= 1) ? 'USESTYLE' : 'disabled="disabled" text=gray' }
+name="RemoveUser" value="Remove User" WIDTH=140 ${(num_accounts > 1) ? 'USESTYLE' : 'disabled="disabled" text=gray' }
TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME="Button1" WIDTH=103>
= minisrv_config.config.user_accounts.max_users_per_account) ? 'disabled="disabled" text=gray' : 'USESTYLE'}
TYPE=SUBMIT BORDERIMAGE="file://ROM/Borders/ButtonBorder2.bif" NAME="Button2" WIDTH=103>
-
+
+
+
+Remove users
+
+
+
+
+
+|
+ |
+
+ |
+|
+ |
+
+
+
+
+ |
+ |
+ |
+
+
+
+ | |
+ |
+
+ |
+ | |
+ |
+
+ | |
+ |
+
+
+
+
+
+`;
+}
\ No newline at end of file
diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-setup/validate-remove-users.js b/zefie_wtvp_minisrv/ServiceVault/wtv-setup/validate-remove-users.js
new file mode 100644
index 00000000..94f38c95
--- /dev/null
+++ b/zefie_wtvp_minisrv/ServiceVault/wtv-setup/validate-remove-users.js
@@ -0,0 +1,74 @@
+var minisrv_service_file = true;
+
+if (Object.keys(ssid_sessions[socket.ssid].listPrimaryAccountUsers()).length == 1) {
+ errpage = wtvshared.doErrorPage(400, "There are no more users to remove.");
+}
+else if (ssid_sessions[socket.ssid].user_id != 0) errpage = wtvshared.doErrorPage(400, "You are not authorized to remove users from this account.");
+
+var usersToRemove = [];
+Object.keys(request_headers.query).forEach(function (k) {
+ if (k.substr(0, 4) === "user" && request_headers.query[k] === "on") {
+ usersToRemove.push(parseInt(k.replace("user", "")));
+ }
+});
+
+if (usersToRemove.length === 0) errpage = wtvshared.doErrorPage(400, "No users were specified for removal.");
+
+if (errpage) {
+ headers = errpage[0];
+ data = errpage[1];
+} else {
+ if (!request_headers.query.confirm_remove) {
+ var message = '';
+ if (usersToRemove.length == 1) {
+ var userSession = new WTVClientSessionData(minisrv_config, socket.ssid);
+ userSession.switchUserID(usersToRemove[0]);
+ var userName = userSession.getSessionData("subscriber_username");
+ message = `Removing ${userName} will permanently remove all of ${userName}'s e-mail and favorites as well. You will not be able to restore ${userName}.`;
+ } else {
+ message = "Removing the selected users will permanently remove their e-mail and favorites as well. You will not be able to restore the users.";
+ }
+ var removeurl = request_headers.request_url;
+ if (removeurl.indexOf('?') >= 0) {
+ removeurl = removeurl.substring(0, removeurl.indexOf('?'));
+ }
+ removeurl += "?";
+
+ Object.keys(usersToRemove).forEach(function (k) {
+ removeurl += "user" + usersToRemove[k] + "=on&";
+ });
+ removeurl += "confirm_remove=true";
+
+ var confirmAlert = new clientShowAlert({
+ 'image': minisrv_config.config.service_logo,
+ 'message': message,
+ 'buttonlabel1': "Don't Remove",
+ 'buttonaction1': "client:donothing",
+ 'buttonlabel2': "Remove",
+ 'buttonaction2': removeurl,
+ 'noback': true,
+ }).getURL();
+ headers = `300 OK
+Connection: Keep-Alive
+Content-Type: text/html
+wtv-expire-all: wtv-setup:/remove-users
+wtv-expire-all: wtv-setup:/accounts
+wtv-visit: ${confirmAlert}
+Location: ${confirmAlert}`
+ } else {
+ Object.keys(usersToRemove).forEach(function (k) {
+ ssid_sessions[socket.ssid].removeUser(usersToRemove[k]);
+ })
+ var num_accounts = ssid_sessions[socket.ssid].getNumberOfUserAccounts();
+ var gourl = "wtv-setup:/remove-users?";
+ if (num_accounts == 1) gourl = "wtv-setup:/accounts?";
+
+ headers = `300 OK
+Connection: Keep-Alive
+Content-Type: text/html
+wtv-expire-all: wtv-setup:/remove-users
+wtv-expire-all: wtv-setup:/accounts
+wtv-visit: ${gourl}
+Location: ${gourl}`
+ }
+}
\ No newline at end of file
diff --git a/zefie_wtvp_minisrv/WTVClientSessionData.js b/zefie_wtvp_minisrv/WTVClientSessionData.js
index 7c1158a0..71d7d8fd 100644
--- a/zefie_wtvp_minisrv/WTVClientSessionData.js
+++ b/zefie_wtvp_minisrv/WTVClientSessionData.js
@@ -173,13 +173,26 @@ class WTVClientSessionData {
* @param subscriber {boolean} Returns the parent subscriber directory instead of the user's directory
* @returns {string|boolean} Absolute path to the user's file store, or false if unregistered
*/
- getUserStoreDirectory(subscriber = false) {
- //if (!this.isRegistered()) return false;
+ getUserStoreDirectory(subscriber = false, user_id = null) {
+ if (user_id == null) user_id = this.user_id;
var userstore = this.minisrv_config.config.SessionStore + this.path.sep + this.ssid + this.path.sep;
- if (!subscriber) userstore += "user" + this.user_id + this.path.sep;
+ if (!subscriber) userstore += "user" + user_id + this.path.sep;
return userstore;
}
+ removeUser(user_id) {
+ if (!this.isRegistered()) return false; // not registered
+ if (parseInt(this.user_id) !== 0) return false; // not primary account
+ if (user_id === 0) return false; // cannot delete primary account in this fashion
+
+ var userstore = this.getUserStoreDirectory(false, user_id);
+ if (this.fs.existsSync(userstore)) {
+ this.fs.rmSync(userstore, { recursive: true });
+ return true;
+ }
+ return false;
+ }
+
/**
* Store a file in the user's file store
* @param {string} path Relative path to User's file store
@@ -496,7 +509,7 @@ class WTVClientSessionData {
this.session_store = {};
}
if (this.fs.existsSync(user_store_base)) {
- this.fs.rmdirSync(user_store_base, { recursive: true });
+ this.fs.rmSync(user_store_base, { recursive: true });
}
return true;
} catch (e) {
diff --git a/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj b/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj
index 171ac3e1..3065ec07 100644
--- a/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj
+++ b/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj
@@ -282,6 +282,8 @@
+
+
Code
|