BREAKING CHANGE: Move accounts into subfolder of SessionStore
- provided migrate_accounts.js for ease of transistion
This commit is contained in:
@@ -99,7 +99,7 @@ class WTVAdmin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAccountInfo(username, directory = null) {
|
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 account_data = null;
|
||||||
var self = this;
|
var self = this;
|
||||||
if (directory) search_dir = directory;
|
if (directory) search_dir = directory;
|
||||||
@@ -114,7 +114,7 @@ class WTVAdmin {
|
|||||||
var temp_session_data = JSON.parse(temp_session_data_file);
|
var temp_session_data = JSON.parse(temp_session_data_file);
|
||||||
|
|
||||||
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) {
|
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) {
|
} catch (e) {
|
||||||
console.error(" # Error parsing Session Data JSON", search_dir + self.path.sep + file, e);
|
console.error(" # Error parsing Session Data JSON", search_dir + self.path.sep + file, e);
|
||||||
|
|||||||
@@ -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
|
* 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
|
* @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) {
|
getUserStoreDirectory(subscriber = false, user_id = null) {
|
||||||
if (user_id == null) user_id = this.user_id;
|
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;
|
if (!subscriber) userstore += "user" + user_id + this.path.sep;
|
||||||
return userstore;
|
return userstore;
|
||||||
}
|
}
|
||||||
@@ -539,7 +543,7 @@ class WTVClientSessionData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unregisterBox() {
|
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 {
|
try {
|
||||||
if (this.fs.existsSync(user_store_base + ".json")) {
|
if (this.fs.existsSync(user_store_base + ".json")) {
|
||||||
this.fs.unlinkSync(user_store_base + ".json");
|
this.fs.unlinkSync(user_store_base + ".json");
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class WTVRegister {
|
|||||||
constructor(minisrv_config, session_store_dir = null) {
|
constructor(minisrv_config, session_store_dir = null) {
|
||||||
this.minisrv_config = minisrv_config;
|
this.minisrv_config = minisrv_config;
|
||||||
this.service_owner = minisrv_config.config.service_owner || "a minisrv user";
|
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) {
|
getServiceOperator(first_letter_lower = false) {
|
||||||
@@ -30,13 +30,12 @@ class WTVRegister {
|
|||||||
|
|
||||||
checkUsernameAvailable(username, directory = null) {
|
checkUsernameAvailable(username, directory = null) {
|
||||||
// returns the user's ssid, and user_id and userid in an array if true, false if not
|
// 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 return_val = false;
|
||||||
var self = this;
|
var self = this;
|
||||||
if (directory) search_dir = directory;
|
if (directory) search_dir = directory;
|
||||||
this.fs.readdirSync(search_dir).forEach(file => {
|
this.fs.readdirSync(search_dir).forEach(file => {
|
||||||
if (self.fs.lstatSync(search_dir + self.path.sep + file).isDirectory() && !return_val) {
|
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);
|
return_val = !self.checkUsernameAvailable(username, search_dir + self.path.sep + file);
|
||||||
}
|
}
|
||||||
if (!file.match(/user.*\.json/ig)) return;
|
if (!file.match(/user.*\.json/ig)) return;
|
||||||
|
|||||||
@@ -38,9 +38,6 @@
|
|||||||
"enable_port_isolation": true,
|
"enable_port_isolation": true,
|
||||||
"allow_guests": true,
|
"allow_guests": true,
|
||||||
"domain_name": "wtv.zefie.com",
|
"domain_name": "wtv.zefie.com",
|
||||||
"ssid_block_list": [
|
|
||||||
"minisrv_internal_nntp"
|
|
||||||
],
|
|
||||||
"user_accounts": {
|
"user_accounts": {
|
||||||
"max_users_per_account": 6,
|
"max_users_per_account": 6,
|
||||||
"min_username_length": 5,
|
"min_username_length": 5,
|
||||||
|
|||||||
27
zefie_wtvp_minisrv/migrate_accounts.js
Normal file
27
zefie_wtvp_minisrv/migrate_accounts.js
Normal file
@@ -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.");
|
||||||
@@ -39,6 +39,9 @@
|
|||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="includes\WTVNewsServer.js" />
|
<Content Include="includes\WTVNewsServer.js" />
|
||||||
|
<Content Include="migrate_accounts.js">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Content>
|
||||||
<Content Include="packer.js" />
|
<Content Include="packer.js" />
|
||||||
<Content Include="ServiceDeps\templates\wtv-guide\glossary.json" />
|
<Content Include="ServiceDeps\templates\wtv-guide\glossary.json" />
|
||||||
<Content Include="ServiceDeps\templates\wtv-guide\prerendered\Alerts\Forbidden.js" />
|
<Content Include="ServiceDeps\templates\wtv-guide\prerendered\Alerts\Forbidden.js" />
|
||||||
@@ -185,7 +188,6 @@
|
|||||||
<Content Include="ServiceVault\wtv-admin\ban.js" />
|
<Content Include="ServiceVault\wtv-admin\ban.js" />
|
||||||
<Content Include="ServiceVault\wtv-admin\deleteaccount.js" />
|
<Content Include="ServiceVault\wtv-admin\deleteaccount.js" />
|
||||||
<Content Include="ServiceVault\wtv-admin\deleteuser.js" />
|
<Content Include="ServiceVault\wtv-admin\deleteuser.js" />
|
||||||
<Content Include="ServiceVault\wtv-admin\findaccount.js" />
|
|
||||||
<Content Include="ServiceVault\wtv-admin\images\nuke.gif" />
|
<Content Include="ServiceVault\wtv-admin\images\nuke.gif" />
|
||||||
<Content Include="ServiceVault\wtv-admin\images\nuke_inverted.gif" />
|
<Content Include="ServiceVault\wtv-admin\images\nuke_inverted.gif" />
|
||||||
<Content Include="ServiceVault\wtv-admin\images\polyzoot.jpg" />
|
<Content Include="ServiceVault\wtv-admin\images\polyzoot.jpg" />
|
||||||
|
|||||||
Reference in New Issue
Block a user