Change copyright, consts, and net events prefix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/v-roleplay
|
||||
// ===========================================================================
|
||||
// FILE: account.js
|
||||
// DESC: Provides account functions and usage
|
||||
@@ -9,35 +8,35 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Account Contact Types
|
||||
const AGRP_CONTACT_NONE = 0;
|
||||
const AGRP_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
|
||||
const AGRP_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
|
||||
const AGRP_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
|
||||
const V_CONTACT_NONE = 0;
|
||||
const V_CONTACT_NEUTRAL = 1; // Contact is neutral. Used for general contacts with no special additional features
|
||||
const V_CONTACT_FRIEND = 2; // Contact is a friend. Shows when they're online.
|
||||
const V_CONTACT_BLOCKED = 3; // Contact is blocked. Prevents all communication to/from them except for RP
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Account Authentication Methods
|
||||
const AGRP_ACCT_AUTHMETHOD_NONE = 0; // None
|
||||
const AGRP_ACCT_AUTHMETHOD_EMAIL = 1; // Email
|
||||
const AGRP_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
|
||||
const AGRP_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
|
||||
const AGRP_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
|
||||
const AGRP_ACCT_AUTHMETHOD_PHONEAPP = 5; // The Android/iOS companion app (will initially be a web based thing until I can get the apps created)
|
||||
const V_ACCT_AUTHMETHOD_NONE = 0; // None
|
||||
const V_ACCT_AUTHMETHOD_EMAIL = 1; // Email
|
||||
const V_ACCT_AUTHMETHOD_PHONENUM = 2; // Phone number
|
||||
const V_ACCT_AUTHMETHOD_2FA = 3; // Two factor authentication app (authy, google authenticator, etc)
|
||||
const V_ACCT_AUTHMETHOD_PEBBLE = 4; // Pebble watch (this one's for Vortrex but anybody with a Pebble can use)
|
||||
const V_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 AGRP_2FA_STATE_NONE = 0; // None
|
||||
const AGRP_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
|
||||
const AGRP_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
|
||||
const AGRP_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
|
||||
const V_2FA_STATE_NONE = 0; // None
|
||||
const V_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter code to play
|
||||
const V_2FA_STATE_SETUP_CODETOAPP = 2; // Providing player with a code to put in their auth app
|
||||
const V_2FA_STATE_SETUP_CODEFROMAPP = 3; // Waiting on player to enter code from auth app to set up
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
// Reset Password States
|
||||
const AGRP_RESETPASS_STATE_NONE = 0; // None
|
||||
const AGRP_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
|
||||
const AGRP_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
|
||||
const V_RESETPASS_STATE_NONE = 0; // None
|
||||
const V_RESETPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email
|
||||
const V_RESETPASS_STATE_SETPASS = 2; // Waiting on player to enter new password
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -866,7 +865,7 @@ function loginSuccess(client) {
|
||||
if (getPlayerData(client).subAccounts.length == 0) {
|
||||
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR;
|
||||
getPlayerData(client).promptType = V_PROMPT_CREATEFIRSTCHAR;
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account] ${getPlayerDisplayForConsole(client)} is being shown the no characters prompt GUI`);
|
||||
} else {
|
||||
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage", `{ALTCOLOUR}/newchar{MAINCOLOUR}`));
|
||||
@@ -1283,7 +1282,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress
|
||||
if (doesServerHaveGUIEnabled() && doesPlayerHaveGUIEnabled(client)) {
|
||||
showPlayerRegistrationSuccessGUI(client);
|
||||
showPlayerPrompt(client, getLocaleString(client, "NoCharactersGUIMessage"), getLocaleString(client, "NoCharactersGUIWindowTitle"), getLocaleString(client, "Yes"), getLocaleString(client, "No"));
|
||||
getPlayerData(client).promptType = AGRP_PROMPT_CREATEFIRSTCHAR;
|
||||
getPlayerData(client).promptType = V_PROMPT_CREATEFIRSTCHAR;
|
||||
} else {
|
||||
messagePlayerAlert(client, getLocaleString(client, "NoCharactersChatMessage", `{ALTCOLOUR}/newchar{MAINCOLOUR}`));
|
||||
}
|
||||
@@ -1298,7 +1297,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
}
|
||||
|
||||
switch (getPlayerData(client).passwordResetState) {
|
||||
case AGRP_RESETPASS_STATE_EMAILCONFIRM: {
|
||||
case V_RESETPASS_STATE_EMAILCONFIRM: {
|
||||
if (toLowerCase(getPlayerData(client).accountData.emailAddress) != toLowerCase(inputText)) {
|
||||
logToConsole(LOG_INFO | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (email not correct)`);
|
||||
showPlayerErrorGUI(client, getLocaleString(client, "GUIErrorResetPasswordFailedInvalidEmail"), getLocaleString(client, "GUIErrorTitle"), getLocaleString(client, "GUIOkButton"));
|
||||
@@ -1306,7 +1305,7 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
}
|
||||
|
||||
let passwordResetCode = toUpperCase(generateEmailVerificationCode());
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_CODEINPUT;
|
||||
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_CODEINPUT;
|
||||
getPlayerData(client).passwordResetCode = passwordResetCode;
|
||||
showPlayerResetPasswordCodeInputGUI(client);
|
||||
sendPasswordResetEmail(client, passwordResetCode);
|
||||
@@ -1314,11 +1313,11 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_RESETPASS_STATE_CODEINPUT: {
|
||||
case V_RESETPASS_STATE_CODEINPUT: {
|
||||
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted code for password reset (${inputText}) ...`);
|
||||
if (inputText != "") {
|
||||
if (getPlayerData(client).passwordResetCode == toUpperCase(inputText)) {
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_SETPASS;
|
||||
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_SETPASS;
|
||||
showPlayerChangePasswordGUI(client);
|
||||
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`);
|
||||
} else {
|
||||
@@ -1335,10 +1334,10 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
break;
|
||||
}
|
||||
|
||||
case AGRP_RESETPASS_STATE_NONE: {
|
||||
case V_RESETPASS_STATE_NONE: {
|
||||
logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} requested a password reset. Awaiting email input ...`);
|
||||
showPlayerResetPasswordEmailInputGUI(client);
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_EMAILCONFIRM;
|
||||
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_EMAILCONFIRM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1350,8 +1349,8 @@ function checkAccountResetPasswordRequest(client, inputText) {
|
||||
|
||||
function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
|
||||
if (!isPlayerLoggedIn(client)) {
|
||||
if (getPlayerData(client).passwordResetState != AGRP_RESETPASS_STATE_SETPASS) {
|
||||
//getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE;
|
||||
if (getPlayerData(client).passwordResetState != V_RESETPASS_STATE_SETPASS) {
|
||||
//getPlayerData(client).passwordResetState = V_RESETPASS_STATE_NONE;
|
||||
//disconnectPlayer(client);
|
||||
logToConsole(LOG_DEBUG | LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to change their password (not logged in or not using reset password)`);
|
||||
return false;
|
||||
@@ -1387,8 +1386,8 @@ function checkAccountChangePassword(client, newPassword, confirmNewPassword) {
|
||||
|
||||
saveAccountToDatabase(getPlayerData(client).accountData);
|
||||
|
||||
if (getPlayerData(client).passwordResetState == AGRP_RESETPASS_STATE_SETPASS) {
|
||||
getPlayerData(client).passwordResetState = AGRP_RESETPASS_STATE_NONE;
|
||||
if (getPlayerData(client).passwordResetState == V_RESETPASS_STATE_SETPASS) {
|
||||
getPlayerData(client).passwordResetState = V_RESETPASS_STATE_NONE;
|
||||
}
|
||||
|
||||
messagePlayerSuccess(client, getLocaleString(client, "PasswordChanged"));
|
||||
@@ -1429,7 +1428,7 @@ function savePlayerToDatabase(client) {
|
||||
//let subAccountData = getPlayerCurrentSubAccount(client);
|
||||
|
||||
if (getPlayerPed(client) != null) {
|
||||
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != AGRP_RETURNTO_TYPE_ADMINGET) {
|
||||
if (getPlayerData(client).returnToPosition != null && getPlayerData(client).returnToType != V_RETURNTO_TYPE_ADMINGET) {
|
||||
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerData(client).returnToPosition;
|
||||
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerData(client).returnToHeading.z;
|
||||
getPlayerCurrentSubAccount(client).interior = getPlayerData(client).returnToInterior;
|
||||
|
||||
Reference in New Issue
Block a user