diff --git a/config/email.json b/config/email.json index 2108d842..ed2b06bf 100644 --- a/config/email.json +++ b/config/email.json @@ -11,6 +11,8 @@ }, "bodyContent": { "confirmEmail": "Welcome to {SERVERNAME}!\nPlease confirm your email by using the command /verifyemail in-game.\n\nYour verification code is: {VERIFICATIONCODE}", + "confirmPasswordReset": "You (or someone else) requested to reset your password on {SERVERNAME}!\nPlease confirm this request by entering the code below into the password reset window in-game.\n\nYour verification code is: {VERIFICATIONCODE}\n\n\nIf you did not request a password reset, then there's nothing to worry about since your password can only be reset with the code above.", + "passwordChanged": "Your password on {SERVERNAME} has been changed successfully!", "emailConfirmed": "Your email has been confirmed on {SERVERNAME}!\nYou may now use this email to reset your password, require two-factor authentication on login, receive offline notifications, and more!", "twoFactorAuthentication": "Please enter the following code to continue on {SERVERNAME} for {GAMENAME}: {2FACODE}", "accountAuthSuccessAlert": "You or someone else has successfully logged in to your account on {SERVERNAME} for {GAMENAME}.\nIP Address: {IPADDRESS}\nLocation: {LOCATION}\nTimestamp: {TIMESTAMP}", diff --git a/scripts/client/gui/changepass.js b/scripts/client/gui/changepass.js index a16a5dfe..ea820b61 100644 --- a/scripts/client/gui/changepass.js +++ b/scripts/client/gui/changepass.js @@ -158,12 +158,15 @@ function showChangePasswordGUI() { setChatWindowEnabled(false); mexui.setInput(true); passwordChange.window.shown = true; + mexui.focusedControl = passwordChange.passwordInput; + guiSubmitKey = checkChangePassword; } // =========================================================================== function passwordChangeSuccess() { logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports password change was successful`); + guiSubmitKey = false; closeAllWindows(); } diff --git a/scripts/client/gui/resetpass.js b/scripts/client/gui/resetpass.js index 16767578..fa8ebb8b 100644 --- a/scripts/client/gui/resetpass.js +++ b/scripts/client/gui/resetpass.js @@ -131,7 +131,8 @@ function showResetPasswordGUI() { setChatWindowEnabled(false); mexui.setInput(true); resetPassword.window.shown = true; - + mexui.focusedControl = resetPassword.emailInput; + guiSubmitButton = checkResetPassword; showSmallGameMessage(`If you don't have a mouse cursor, press ${toUpperCase(getKeyNameFromId(disableGUIKey))} to disable GUI`, COLOUR_WHITE, 7500); } @@ -153,14 +154,21 @@ function resetPasswordFailed(errorMessage) { // =========================================================================== -function resetPasswordSuccess() { +function resetPasswordCodeStep() { logToConsole(LOG_DEBUG, `[VRR.GUI] Server reports password reset was successful`); + + resetPassword.messageLabel.text = "Check your email for a reset code"; + resetPassword.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); + resetPassword.emailInput.text = ""; + + guiSubmitKey = false; closeAllWindows(); } // =========================================================================== function switchToLoginGUI() { + guiSubmitKey = false; closeAllWindows(); showLoginGUI(); } diff --git a/scripts/server/class.js b/scripts/server/class.js index babff1e1..814ede45 100644 --- a/scripts/server/class.js +++ b/scripts/server/class.js @@ -258,6 +258,9 @@ class ClientData { this.currentAnimationPositionReturnTo = false; this.animationStart = 0; this.animationForced = false; + + this.passwordResetState = VRR_RESETPASS_STATE_NONE; + this.passwordResetCode = ""; } }; diff --git a/scripts/server/client.js b/scripts/server/client.js index cbdc980c..74e64e90 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -48,6 +48,8 @@ function addAllNetworkHandlers() { // Account addNetworkHandler("vrr.checkLogin", checkLogin); addNetworkHandler("vrr.checkRegistration", checkRegistration); + addNetworkHandler("vrr.checkResetPassword", checkAccountResetPasswordRequest); + addNetworkHandler("vrr.checkChangePassword", checkAccountChangePassword); // Developer addNetworkHandler("vrr.runCodeSuccess", clientRunCodeSuccess); @@ -288,6 +290,13 @@ function sendJobRouteStopToPlayer(client, position, colour) { // =========================================================================== +function showPlayerChangePasswordGUI(client) { + logToConsole(LOG_DEBUG, `[VRR.Client] Sending change password GUI signal to ${getPlayerDisplayForConsole(client)}`); + triggerNetworkEvent("vrr.changePassword", client); +} + +// =========================================================================== + function showPlayerLoginSuccessGUI(client) { logToConsole(LOG_DEBUG, `[VRR.Client] Sending login success GUI signal to ${getPlayerDisplayForConsole(client)}`); triggerNetworkEvent("vrr.loginSuccess", client); diff --git a/scripts/server/const.js b/scripts/server/const.js index ddd55ba2..4833f562 100644 --- a/scripts/server/const.js +++ b/scripts/server/const.js @@ -292,9 +292,9 @@ const VRR_2FA_STATE_CODEINPUT = 1; // Waiting on player to enter c 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 -const VRR_FORGOTPASS_STATE_NONE = 0; // None -const VRR_FORGOTPASS_STATE_CODEINPUT = 1; // Waiting on player to enter code sent via email -const VRR_FORGOTPASS_STATE_SETPASS = 2; // Waiting on player to enter new password +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 const VRR_NPC_COND_MATCH_NONE = 0; // None (invalid) const VRR_NPC_COND_MATCH_EQ = 1; // Must be equal to