diff --git a/scripts/client/gui/resetpass.js b/scripts/client/gui/resetpass.js index f81eafc4..c04ebf17 100644 --- a/scripts/client/gui/resetpass.js +++ b/scripts/client/gui/resetpass.js @@ -20,8 +20,8 @@ let passwordReset = { // =========================================================================== function initResetPasswordGUI() { - logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password reset GUI ...`); - passwordReset.window = mexui.window(getScreenWidth()/2-150, getScreenHeight()/2-135, 300, 275, 'RESET PASSWORD', { + logToConsole(LOG_DEBUG, `[VRR.GUI] Creating password reset GUI ...`); + passwordReset.window = mexui.window(getScreenWidth() / 2 - 150, getScreenHeight() / 2 - 135, 300, 275, 'RESET PASSWORD', { main: { backgroundColour: toColour(secondaryColour[0], secondaryColour[1], secondaryColour[2], windowAlpha), transitionTime: 500, @@ -38,7 +38,7 @@ function initResetPasswordGUI() { borderColour: toColour(0, 0, 0, 0), }, }); - passwordReset.window.titleBarIconSize = toVector2(0,0); + passwordReset.window.titleBarIconSize = toVector2(0, 0); passwordReset.window.titleBarHeight = 0; passwordReset.window.titleBarShown = false; @@ -82,7 +82,7 @@ function initResetPasswordGUI() { }); passwordReset.emailInput.placeholder = "Email"; - passwordReset.resetPasswordButton = passwordReset.window.button(180, 240, 100, 15, 'RESET PASSWORD', { + passwordReset.resetPasswordButton = passwordReset.window.button(20, 205, 260, 30, 'RESET PASSWORD', { main: { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), textColour: toColour(primaryTextColour[0], primaryTextColour[1], primaryTextColour[2], 255), @@ -134,14 +134,14 @@ function showResetPasswordGUI() { mexui.focusedControl = passwordReset.emailInput; guiSubmitKey = checkResetPassword; - showLocaleChooserGUI(new Vec2(getScreenWidth()/2-(localeChooser.window.size.x/2), passwordReset.window.position.y+passwordReset.window.size.y+20)); + showLocaleChooserGUI(new Vec2(getScreenWidth() / 2 - (localeChooser.window.size.x / 2), passwordReset.window.position.y + passwordReset.window.size.y + 20)); //showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500); } // =========================================================================== function checkResetPassword() { - logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server ...`); + logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password reset with server (${passwordReset.emailInput.lines[0]}) ...`); sendNetworkEventToServer("vrr.checkResetPassword", passwordReset.emailInput.lines[0]); } @@ -157,12 +157,12 @@ function resetPasswordFailed(errorMessage) { // =========================================================================== function resetPasswordCodeInputGUI() { - logToConsole(LOG_DEBUG|LOG_WARN, `[VRR.GUI] Server reports password reset email confirmation was successful. Asking for code ...`); + logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset email confirmation was successful. Asking for code ...`); closeAllWindows(); passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordCodeInputLabel"); //passwordReset.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); - passwordReset.emailInput.text = ""; + passwordReset.emailInput.lines[0] = ""; passwordReset.emailInput.placeholder = getLocaleString("GUIResetPasswordCodePlaceholder"); guiSubmitKey = checkResetPassword; @@ -172,7 +172,7 @@ function resetPasswordCodeInputGUI() { // =========================================================================== function resetPasswordEmailInputGUI() { - logToConsole(LOG_DEBUG|LOG_WARN, `[VRR.GUI] Server reports password reset request was approved. Asking for email ...`); + logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.GUI] Server reports password reset request was approved. Asking for email ...`); closeAllWindows(); passwordReset.messageLabel.text = getLocaleString("GUIResetPasswordConfirmEmailLabel"); @@ -188,8 +188,8 @@ function resetPasswordEmailInputGUI() { function switchToLoginGUI() { guiSubmitKey = false; - closeAllWindows(); - showLoginGUI(); + closeAllWindows(); + showLoginGUI(); } // =========================================================================== \ No newline at end of file diff --git a/scripts/server/account.js b/scripts/server/account.js index 0214fd8f..c2e4f7a0 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -801,9 +801,10 @@ function createAccount(name, password, email = "") { // =========================================================================== -function checkLogin(client, password) { +async function checkLogin(client, password) { getPlayerData(client).loginAttemptsRemaining = getPlayerData(client).loginAttemptsRemaining - 1; if (getPlayerData(client).loginAttemptsRemaining <= 0) { + getPlayerData(client).customDisconnectReason = "Kicked - Failed to login"; disconnectPlayer(client); } @@ -842,7 +843,7 @@ function checkLogin(client, password) { // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { - // sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); + // await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); //} return false; } @@ -859,7 +860,7 @@ function checkLogin(client, password) { // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { - // sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); + // await sendAccountLoginFailedNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); //} return false; } @@ -879,7 +880,7 @@ function checkLogin(client, password) { // Disabling email login alerts for now. It hangs the server for a couple seconds. Need a way to thread it. //if (isAccountEmailVerified(getPlayerData(client).accountData) && !isAccountSettingFlagEnabled(getPlayerData(client).accountData, getAccountSettingsFlagValue("AuthAttemptAlert"))) { - // sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); + // await sendAccountLoginSuccessNotification(getPlayerData(client).accountData.emailAddress, getPlayerName(client), getPlayerIP(client), getGame()); //} } @@ -987,6 +988,7 @@ function checkRegistration(client, password, confirmPassword = "", emailAddress if (doesServerHaveTesterOnlyEnabled() && !isPlayerATester(client)) { setTimeout(function () { + getPlayerData(client).customDisconnectReason = "Kicked - Not a tester"; disconnectPlayer(client); }, 5000); @@ -1032,22 +1034,23 @@ function checkAccountResetPasswordRequest(client, inputText) { getPlayerData(client).passwordResetCode = passwordResetCode; showPlayerResetPasswordCodeInputGUI(client); sendPasswordResetEmail(client, passwordResetCode); - logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted successful email for password reset. Sending email and awaiting verification code input ...`); + logToConsole(LOG_INFO, `${getPlayerDisplayForConsole(client)} submitted successful email for password reset. Sending email and awaiting verification code input (${passwordResetCode}) ...`); break; } case VRR_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 = VRR_RESETPASS_STATE_SETPASS; - showPlayerChangePasswordGUI(client, getLocaleString(client)); + showPlayerChangePasswordGUI(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 ...)`); + getPlayerData(client).customDisconnectReason = "Kicked - Failed to login"; disconnectPlayer(client); return false; } @@ -1570,6 +1573,7 @@ function checkPlayerTwoFactorAuthentication(client, authCode) { } } + getPlayerData(client).customDisconnectReason = "Kicked - Failed to login"; disconnectPlayer(client); return false; }