user account updates

- move user accounts to subdir
- add password support
- implemented basics of multi-user support
- Can add users, edit them, and log in with them (password or not)
- Cannot delete users (with service) yet
This commit is contained in:
zefie
2022-02-07 20:24:16 -05:00
parent 622698ee66
commit 0d991d5eac
35 changed files with 2228 additions and 154 deletions

View File

@@ -28,13 +28,19 @@ class WTVRegister {
return (check1 && check2);
}
checkUsernameAvailable(username, ssid_sessions) {
checkUsernameAvailable(username, ssid_sessions, directory = null) {
var username_match = false;
this.fs.readdirSync(this.session_store_dir).forEach(file => {
var search_dir = this.session_store_dir;
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 self.checkUsernameAvailable(username, ssid_sessions, search_dir + self.path.sep + file);
}
if (!file.match(/.*\.json/ig)) return;
if (username_match) return;
try {
var temp_session_data_file = this.fs.readFileSync(this.session_store_dir + this.path.sep + file, 'Utf8');
var temp_session_data_file = this.fs.readFileSync(search_dir + this.path.sep + file, 'Utf8');
var temp_session_data = JSON.parse(temp_session_data_file);
if (temp_session_data.subscriber_username.toLowerCase() == username.toLowerCase()) username_match = true;
} catch (e) {