Restructure (unfinished)
This commit is contained in:
@@ -7,6 +7,191 @@
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
// Account Contact Types
|
||||
const VRR_CONTACT_NONE = 0;
|
||||
const VRR_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
|
||||
const VRR_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
|
||||
const VRR_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Account Authentication Methods
|
||||
const VRR_ACCT_AUTHMETHOD_NONE = 0; // None
|
||||
const VRR_ACCT_AUTHMETHOD_EMAIL = 1; // Email
|
||||
const VRR_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
|
||||
const VRR_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
|
||||
const VRR_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
|
||||
const VRR_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Two-Factor Authentication States
|
||||
const VRR_2FA_STATE_NONE = 0; // None
|
||||
const VRR_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
|
||||
const VRR_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
|
||||
const VRR_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Reset Password States
|
||||
const VRR_RESETPASS_STATE_NONE = 0; // None
|
||||
const VRR_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
|
||||
const VRR_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing an account, loaded/saved in the database
|
||||
*/
|
||||
class AccountData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.name = "";
|
||||
this.password = "";
|
||||
this.registerDate = 0;
|
||||
this.flags = {
|
||||
moderation: 0,
|
||||
admin: 0,
|
||||
};
|
||||
this.staffTitle = "";
|
||||
this.ircAccount = "";
|
||||
this.discordAccount = 0,
|
||||
this.settings = 0,
|
||||
this.emailAddress = "";
|
||||
this.ipAddress = 0,
|
||||
|
||||
this.notes = [];
|
||||
this.messages = [];
|
||||
this.contacts = [];
|
||||
this.subAccounts = [];
|
||||
|
||||
this.emailVerificationCode = "";
|
||||
this.twoFactorAuthVerificationCode = "";
|
||||
|
||||
this.chatScrollLines = 1;
|
||||
|
||||
this.streamingRadioVolume = 20;
|
||||
this.locale = 0;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["acct_id"];
|
||||
this.name = dbAssoc["acct_name"];
|
||||
this.password = dbAssoc["acct_pass"];
|
||||
this.registerDate = dbAssoc["acct_when_made"];
|
||||
this.flags = {
|
||||
moderation: dbAssoc["acct_svr_mod_flags"],
|
||||
admin: dbAssoc["acct_svr_staff_flags"],
|
||||
};
|
||||
this.staffTitle = dbAssoc["acct_svr_staff_title"];
|
||||
this.ircAccount = dbAssoc["acct_irc"];
|
||||
this.discordAccount = dbAssoc["acct_discord"];
|
||||
this.settings = dbAssoc["acct_svr_settings"];
|
||||
this.emailAddress = dbAssoc["acct_email"];
|
||||
this.whenRegistered = dbAssoc["acct_when_registered"];
|
||||
this.ipAddress = dbAssoc["acct_ip"];
|
||||
|
||||
this.notes = [];
|
||||
this.messages = [];
|
||||
this.contacts = [];
|
||||
this.subAccounts = [];
|
||||
|
||||
this.emailVerificationCode = dbAssoc["acct_code_verifyemail"];
|
||||
this.twoFactorAuthVerificationCode = dbAssoc["acct_code_2fa"];
|
||||
this.chatScrollLines = toInteger(dbAssoc["acct_svr_chat_scroll_lines"]);
|
||||
this.streamingRadioVolume = toInteger(dbAssoc["acct_streaming_radio_volume"]);
|
||||
this.locale = toInteger(dbAssoc["acct_locale"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing an account's contact list, loaded/saved in the database
|
||||
*/
|
||||
class AccountContactData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.accountId = 0;
|
||||
this.contactAccountId = 0;
|
||||
this.type = 0;
|
||||
this.whenAdded = 0;
|
||||
this.needsSaved = false;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["acct_contact_id"];
|
||||
this.accountId = dbAssoc["acct_contact_acct"];
|
||||
this.contactAccountId = dbAssoc["acct_contact_contact"];
|
||||
this.type = dbAssoc["acct_contact_type"];
|
||||
this.whenAdded = dbAssoc["acct_contact_when_added"];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing an account's messages, loaded/saved in the database
|
||||
*/
|
||||
class AccountMessageData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.account = 0;
|
||||
this.whoSent = 0;
|
||||
this.whenSent = 0;
|
||||
this.whenRead = 0;
|
||||
this.deleted = false;
|
||||
this.whenDeleted = 0;
|
||||
this.folder = 0;
|
||||
this.message = "";
|
||||
this.needsSaved = false;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["acct_msg_id"];
|
||||
this.account = dbAssoc["acct_msg_acct"];
|
||||
this.whoSent = dbAssoc["acct_msg_who_sent"];
|
||||
this.whenSent = dbAssoc["acct_msg_when_sent"];
|
||||
this.whenRead = dbAssoc["acct_msg_when_read"];
|
||||
this.deleted = intToBool(dbAssoc["acct_msg_deleted"]);
|
||||
this.whenDeleted = dbAssoc["acct_msg_when_deleted"];
|
||||
this.folder = dbAssoc["acct_msg_folder"];
|
||||
this.message = dbAssoc["acct_msg_message"];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
/**
|
||||
* @class Representing an account's staff notes. Visible only to staff and loaded/saved in the database
|
||||
*/
|
||||
class AccountStaffNoteData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.account = 0;
|
||||
this.whoAdded = 0;
|
||||
this.whenAdded = 0;
|
||||
this.deleted = false;
|
||||
this.whenDeleted = 0;
|
||||
this.serverId = 0;
|
||||
this.note = "";
|
||||
this.needsSaved = false;
|
||||
|
||||
if(dbAssoc) {
|
||||
this.databaseId = dbAssoc["acct_note_id"];
|
||||
this.account = dbAssoc["acct_note_acct"];
|
||||
this.whoAdded = dbAssoc["acct_note_who_added"];
|
||||
this.whenAdded = dbAssoc["acct_note_when_added"];
|
||||
this.deleted = intToBool(dbAssoc["acct_note_deleted"]);
|
||||
this.whenDeleted = dbAssoc["acct_note_when_deleted"];
|
||||
this.serverId = dbAssoc["acct_note_server"];
|
||||
this.note = dbAssoc["acct_note_message"];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function initAccountScript() {
|
||||
logToConsole(LOG_DEBUG, "[VRR.Account]: Initializing account script ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.Account]: Account script initialized!");
|
||||
|
||||
Reference in New Issue
Block a user