diff --git a/zefie_wtvp_minisrv/includes/WTVAdmin.js b/zefie_wtvp_minisrv/includes/WTVAdmin.js index a358467b..76201d60 100644 --- a/zefie_wtvp_minisrv/includes/WTVAdmin.js +++ b/zefie_wtvp_minisrv/includes/WTVAdmin.js @@ -99,7 +99,7 @@ class WTVAdmin { } getAccountInfo(username, directory = null) { - var search_dir = this.minisrv_config.config.SessionStore; + var search_dir = this.minisrv_config.config.SessionStore + this.path.sep + "accounts"; var account_data = null; var self = this; if (directory) search_dir = directory; @@ -114,7 +114,7 @@ class WTVAdmin { var temp_session_data = JSON.parse(temp_session_data_file); if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) { - account_data = [temp_session_data, (search_dir + self.path.sep + file).replace(this.minisrv_config.config.SessionStore + this.path.sep, "").split(this.path.sep)[0]]; + account_data = [temp_session_data, (search_dir + self.path.sep + file).replace(this.minisrv_config.config.SessionStore + this.path.sep + "accounts", "").split(this.path.sep)[1]]; } } catch (e) { console.error(" # Error parsing Session Data JSON", search_dir + self.path.sep + file, e); diff --git a/zefie_wtvp_minisrv/includes/WTVClientSessionData.js b/zefie_wtvp_minisrv/includes/WTVClientSessionData.js index 33687c8c..50103ffa 100644 --- a/zefie_wtvp_minisrv/includes/WTVClientSessionData.js +++ b/zefie_wtvp_minisrv/includes/WTVClientSessionData.js @@ -188,6 +188,10 @@ class WTVClientSessionData { ); } + getAccountStoreDirectory() { + return this.minisrv_config.config.SessionStore + this.path.sep + "accounts"; + } + /** * Returns the absolute path to the user's file store, or false if unregistered * @param subscriber {boolean} Returns the parent subscriber directory instead of the user's directory @@ -195,7 +199,7 @@ class WTVClientSessionData { */ 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; + var userstore = this.getAccountStoreDirectory() + this.path.sep + this.ssid + this.path.sep; if (!subscriber) userstore += "user" + user_id + this.path.sep; return userstore; } @@ -539,7 +543,7 @@ class WTVClientSessionData { } unregisterBox() { - var user_store_base = this.wtvshared.makeSafePath(this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore), this.path.sep + this.ssid); + var user_store_base = this.wtvshared.makeSafePath(this.wtvshared.getAbsolutePath(this.getAccountStoreDirectory()), this.path.sep + this.ssid); try { if (this.fs.existsSync(user_store_base + ".json")) { this.fs.unlinkSync(user_store_base + ".json"); diff --git a/zefie_wtvp_minisrv/includes/WTVRegister.js b/zefie_wtvp_minisrv/includes/WTVRegister.js index 9884f0d1..c798e19d 100644 --- a/zefie_wtvp_minisrv/includes/WTVRegister.js +++ b/zefie_wtvp_minisrv/includes/WTVRegister.js @@ -9,7 +9,7 @@ class WTVRegister { constructor(minisrv_config, session_store_dir = null) { this.minisrv_config = minisrv_config; this.service_owner = minisrv_config.config.service_owner || "a minisrv user"; - if (session_store_dir) this.session_store_dir = session_store_dir + this.session_store_dir = session_store_dir || this.minisrv_config.config.SessionStore; } getServiceOperator(first_letter_lower = false) { @@ -30,13 +30,12 @@ class WTVRegister { checkUsernameAvailable(username, directory = null) { // returns the user's ssid, and user_id and userid in an array if true, false if not - var search_dir = this.minisrv_config.config.SessionStore; + var search_dir = this.session_store_dir + this.path.sep + "accounts"; var return_val = false; var self = this; if (directory) search_dir = directory; this.fs.readdirSync(search_dir).forEach(file => { if (self.fs.lstatSync(search_dir + self.path.sep + file).isDirectory() && !return_val) { - if (search_dir.match(/minisrv\_internal\_nntp/)) return; return_val = !self.checkUsernameAvailable(username, search_dir + self.path.sep + file); } if (!file.match(/user.*\.json/ig)) return; diff --git a/zefie_wtvp_minisrv/includes/config.json b/zefie_wtvp_minisrv/includes/config.json index 0c3a8049..0f27d281 100644 --- a/zefie_wtvp_minisrv/includes/config.json +++ b/zefie_wtvp_minisrv/includes/config.json @@ -38,9 +38,6 @@ "enable_port_isolation": true, "allow_guests": true, "domain_name": "wtv.zefie.com", - "ssid_block_list": [ - "minisrv_internal_nntp" - ], "user_accounts": { "max_users_per_account": 6, "min_username_length": 5, diff --git a/zefie_wtvp_minisrv/migrate_accounts.js b/zefie_wtvp_minisrv/migrate_accounts.js new file mode 100644 index 00000000..b1304403 --- /dev/null +++ b/zefie_wtvp_minisrv/migrate_accounts.js @@ -0,0 +1,27 @@ +var classPath = __dirname + "/includes/"; +const { WTVShared } = require(classPath + "WTVShared.js"); +const wtvshared = new WTVShared(); // creates minisrv_config +classPath = wtvshared.getAbsolutePath(classPath, __dirname); +const WTVClientSessionData = require(classPath + "/WTVClientSessionData.js"); +minisrv_config = wtvshared.getMiniSrvConfig(); + +const wtvcsd = new WTVClientSessionData(minisrv_config) + +const fs = require('fs') +const path = require('path') + + +var old_account_dir = minisrv_config.config.SessionStore; +var new_account_dir = wtvcsd.getAccountStoreDirectory(); +if (!fs.existsSync(new_account_dir)) fs.mkdirSync(new_account_dir); + +total = 0; + +fs.readdirSync(old_account_dir).forEach(file => { + if (file === "accounts" || file === "minisrv_internal_nntp" || file === "client registration and session data will populate here.txt") return; + fs.renameSync(old_account_dir + path.sep + file, new_account_dir + path.sep + file) + console.log(" * Migrated", old_account_dir + path.sep + file, "to", new_account_dir + path.sep + file); + total++; +}); + +console.log(" *", total, "accounts migrated."); \ No newline at end of file diff --git a/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj b/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj index 7e544678..2209402f 100644 --- a/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj +++ b/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj @@ -39,6 +39,9 @@ Code + + Code + @@ -185,7 +188,6 @@ -