update checkUserExists and inconsistencies
This commit is contained in:
@@ -14,7 +14,7 @@ if (!request_headers.query.registering) {
|
|||||||
else if (request_headers.query.subscriber_username.length < minisrv_config.config.user_accounts.min_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.min_length + " or more characters.");
|
else if (request_headers.query.subscriber_username.length < minisrv_config.config.user_accounts.min_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.min_length + " or more characters.");
|
||||||
else if (request_headers.query.subscriber_username.length > minisrv_config.config.user_accounts.max_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.max_length + " or less characters.");
|
else if (request_headers.query.subscriber_username.length > minisrv_config.config.user_accounts.max_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.max_length + " or less characters.");
|
||||||
else if (!wtvr.checkUsernameSanity(request_headers.query.subscriber_username)) errpage = wtvshared.doErrorPage(400, "The username you have chosen contains invalid characters. Please choose a username with only <b>letters</b>, <b>numbers</b>, <b>_</b> or <b>-</b>. Also, please be sure your username begins with a letter.");
|
else if (!wtvr.checkUsernameSanity(request_headers.query.subscriber_username)) errpage = wtvshared.doErrorPage(400, "The username you have chosen contains invalid characters. Please choose a username with only <b>letters</b>, <b>numbers</b>, <b>_</b> or <b>-</b>. Also, please be sure your username begins with a letter.");
|
||||||
else if (!wtvr.checkUsernameAvailable(request_headers.query.subscriber_username, ssid_sessions)) errpage = wtvshared.doErrorPage(400, "The username you have selected is already in use. Please select another username.");
|
else if (!wtvr.checkUsernameAvailable(request_headers.query.subscriber_username)) errpage = wtvshared.doErrorPage(400, "The username you have selected is already in use. Please select another username.");
|
||||||
else if (!request_headers.query.subscriber_contact) errpage = wtvshared.doErrorPage(400, "Please enter your contact information.");
|
else if (!request_headers.query.subscriber_contact) errpage = wtvshared.doErrorPage(400, "Please enter your contact information.");
|
||||||
else if (request_headers.query.subscriber_contact_method == "") errpage = wtvshared.doErrorPage(400, "Please select the type of contact information you provided.");
|
else if (request_headers.query.subscriber_contact_method == "") errpage = wtvshared.doErrorPage(400, "Please select the type of contact information you provided.");
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ else if (!request_headers.query.user_name) errpage = doErrorPage(400, "Please en
|
|||||||
else if (request_headers.query.user_name.length < minisrv_config.config.user_accounts.min_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.min_length + " or more characters.");
|
else if (request_headers.query.user_name.length < minisrv_config.config.user_accounts.min_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.min_length + " or more characters.");
|
||||||
else if (request_headers.query.user_name.length > minisrv_config.config.user_accounts.max_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.max_length + " or less characters.");
|
else if (request_headers.query.user_name.length > minisrv_config.config.user_accounts.max_length) errpage = wtvshared.doErrorPage(400, "Please choose a username with " + minisrv_config.config.user_accounts.max_length + " or less characters.");
|
||||||
else if (!wtvr.checkUsernameSanity(request_headers.query.user_name)) errpage = wtvshared.doErrorPage(400, "The username you have chosen contains invalid characters. Please choose a username with only <b>letters</b>, <b>numbers</b>, <b>_</b> or <b>-</b>. Also, please be sure your username begins with a letter.");
|
else if (!wtvr.checkUsernameSanity(request_headers.query.user_name)) errpage = wtvshared.doErrorPage(400, "The username you have chosen contains invalid characters. Please choose a username with only <b>letters</b>, <b>numbers</b>, <b>_</b> or <b>-</b>. Also, please be sure your username begins with a letter.");
|
||||||
else if (!wtvr.checkUsernameAvailable(request_headers.query.user_name, ssid_sessions)) errpage = wtvshared.doErrorPage(400, "The username you have selected is already in use. Please select another username.");
|
else if (!wtvr.checkUsernameAvailable(request_headers.query.user_name)) errpage = wtvshared.doErrorPage(400, "The username you have selected is already in use. Please select another username.");
|
||||||
else if (ssid_sessions[socket.ssid].getNumberOfUserAccounts() > minisrv_config.config.user_accounts.max_users_per_account) errpage = wtvshared.doErrorPage(400, "You are not authorized to add more than " + minisrv_config.config.user_accounts.max_users_per_account + ` account${minisrv_config.config.user_accounts.max_users_per_account > 1 ? 's' : ''}.`);
|
else if (ssid_sessions[socket.ssid].getNumberOfUserAccounts() > minisrv_config.config.user_accounts.max_users_per_account) errpage = wtvshared.doErrorPage(400, "You are not authorized to add more than " + minisrv_config.config.user_accounts.max_users_per_account + ` account${minisrv_config.config.user_accounts.max_users_per_account > 1 ? 's' : ''}.`);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -290,8 +290,8 @@ class WTVMail {
|
|||||||
return icon_image;
|
return icon_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkUserExists(username) {
|
checkUserExists(username, directory = null) {
|
||||||
// returns the user's SSID if true, false if not
|
// returns the user's username if true, false if not
|
||||||
var username_match = false;
|
var username_match = false;
|
||||||
var search_dir = this.session_store_dir;
|
var search_dir = this.session_store_dir;
|
||||||
var return_val = false;
|
var return_val = false;
|
||||||
@@ -299,7 +299,7 @@ class WTVMail {
|
|||||||
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()) {
|
if (self.fs.lstatSync(search_dir + self.path.sep + file).isDirectory()) {
|
||||||
return self.checkUsernameAvailable(username, ssid_sessions, search_dir + self.path.sep + file);
|
return self.checkUserExists(username, search_dir + self.path.sep + file);
|
||||||
}
|
}
|
||||||
if (!file.match(/.*\.json/ig)) return;
|
if (!file.match(/.*\.json/ig)) return;
|
||||||
if (username_match) return;
|
if (username_match) return;
|
||||||
|
|||||||
@@ -28,14 +28,21 @@ class WTVRegister {
|
|||||||
return (check1 && check2);
|
return (check1 && check2);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkUsernameAvailable(username, ssid_sessions, directory = null) {
|
checkUsernameAvailable(username, directory = null) {
|
||||||
var username_match = false;
|
var username_match = false;
|
||||||
var search_dir = this.session_store_dir;
|
var search_dir = this.session_store_dir;
|
||||||
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()) {
|
if (self.fs.lstatSync(search_dir + self.path.sep + file).isDirectory()) {
|
||||||
return self.checkUsernameAvailable(username, ssid_sessions, search_dir + self.path.sep + file);
|
return self.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(username, search_dir + self.path.sep + file);
|
||||||
}
|
}
|
||||||
if (!file.match(/.*\.json/ig)) return;
|
if (!file.match(/.*\.json/ig)) return;
|
||||||
if (username_match) return;
|
if (username_match) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user