From 9d30a0256829ef5a54b216bbffd6edfe76f27370 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 22 May 2022 23:34:34 -0500 Subject: [PATCH] Exclude blank code + 3 pass reset code attempts --- scripts/server/account.js | 23 +++++++++++++++-------- scripts/server/business.js | 17 +++++++++++++---- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/scripts/server/account.js b/scripts/server/account.js index a431bc5f..8f68aa8c 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -1034,14 +1034,21 @@ function checkAccountResetPasswordRequest(client, inputText) { } case VRR_RESETPASS_STATE_CODEINPUT: { - if(getPlayerData(client).passwordResetCode == toUpperCase(inputText)) { - getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_SETPASS; - showPlayerChangePasswordGUI(client, getLocaleString(client)); - logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`); - } else { - getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; - disconnectPlayer(client); - logToConsole(LOG_INFO|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct)`); + if(inputText != "") { + if(getPlayerData(client).passwordResetCode == toUpperCase(inputText)) { + getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_SETPASS; + showPlayerChangePasswordGUI(client, getLocaleString(client)); + logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} entered the correct reset password verification code. Awaiting new password input ...`); + } else { + getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; + getPlayerData(client).passwordResetAttemptsRemaining = getPlayerData(client).passwordResetAttemptsRemaining - 1; + logToConsole(LOG_INFO|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, ${getPlayerData(client).passwordResetAttemptsRemaining} attempts remaining)`); + if(getPlayerData(client).passwordResetAttemptsRemaining <= 0) { + logToConsole(LOG_INFO|LOG_WARN, `${getPlayerDisplayForConsole(client)} failed to reset their password (verification code not correct, no more attempts remaining, kicking ...)`); + disconnectPlayer(client); + return false; + } + } } break; } diff --git a/scripts/server/business.js b/scripts/server/business.js index 46bc86d6..cc1d85b1 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -2499,10 +2499,19 @@ function cacheBusinessItems(businessId) { clearArray(getBusinessData(businessId).floorItemCache); clearArray(getBusinessData(businessId).storageItemCache); - let businessData = getBusinessData(businessId); - logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${businessData.name}) ...`); - getBusinessData(businessId).floorItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZFLOOR && item.ownerId == businessData.databaseId); - getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId); + //let businessData = getBusinessData(businessId); + //logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${businessData.name}) ...`); + //getBusinessData(businessId).floorItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZFLOOR && item.ownerId == businessData.databaseId).map(i => i.index); + //getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == VRR_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId); + + logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`); + for(let i in getServerData().items) { + if(getItemData(i).ownerType == VRR_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { + getBusinessData(businessId).floorItemCache.push(i); + } else if(getItemData(i).ownerType == VRR_ITEM_OWNER_BIZSTORAGE && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { + getBusinessData(businessId).storageItemCache.push(i); + } + } logToConsole(LOG_VERBOSE, `[VRR.Business] Successfully cached ${getBusinessData(businessId).floorItemCache.length} floor items and ${getBusinessData(businessId).storageItemCache} storage items for business ${businessId} (${getBusinessData(businessId).name})!`); }