diff --git a/scripts/client/gui/changepass.js b/scripts/client/gui/changepass.js index ea820b61..c6329e5c 100644 --- a/scripts/client/gui/changepass.js +++ b/scripts/client/gui/changepass.js @@ -13,7 +13,6 @@ let passwordChange = { messageLabel: null, passwordInput: null, confirmPasswordInput: null, - verificationCodeInput: null, submitButton: null, }; @@ -40,13 +39,13 @@ function initChangePasswordGUI() { passwordChange.window.titleBarIconSize = toVector2(0,0); passwordChange.window.titleBarHeight = 0; - passwordChange.window.image(115, 10, 65, 65, mainLogoPath, { + passwordChange.window.image(85, -10, 140, 140, mainLogoPath, { focused: { borderColour: toColour(0, 0, 0, 0), }, }); - passwordChange.messageLabel = passwordChange.window.text(20, 75, 260, 20, 'Check your email for a verification code!', { + passwordChange.messageLabel = passwordChange.window.text(20, 75, 260, 20, 'Enter a new password', { main: { textSize: 10.0, textAlign: 0.5, @@ -58,7 +57,7 @@ function initChangePasswordGUI() { }, }); - passwordChange.passwordInput = passwordChange.window.textInput(20, 100, 260, 25, '', { + passwordChange.passwordInput = passwordChange.window.textInput(20, 130, 260, 25, '', { main: { backgroundColour: toColour(0, 0, 0, 120), textColour: toColour(200, 200, 200, 255), @@ -78,7 +77,7 @@ function initChangePasswordGUI() { passwordChange.passwordInput.masked = true; passwordChange.passwordInput.placeholder = "Password"; - passwordChange.confirmPasswordInput = passwordChange.window.textInput(20, 130, 260, 25, '', { + passwordChange.confirmPasswordInput = passwordChange.window.textInput(20, 160, 260, 25, '', { main: { backgroundColour: toColour(0, 0, 0, 120), textColour: toColour(200, 200, 200, 255), @@ -98,25 +97,6 @@ function initChangePasswordGUI() { passwordChange.confirmPasswordInput.masked = true; passwordChange.confirmPasswordInput.placeholder = "Confirm password"; - passwordChange.verificationCodeInput = passwordChange.window.textInput(20, 160, 260, 25, '', { - main: { - backgroundColour: toColour(0, 0, 0, 120), - textColour: toColour(200, 200, 200, 255), - textSize: 10.0, - textFont: robotoFont, - }, - caret: { - lineColour: toColour(255, 255, 255, 255), - }, - placeholder: { - backgroundColour: toColour(0, 0, 0, 120), - textColour: toColour(200, 200, 200, 200), - textSize: 10.0, - textFont: robotoFont, - } - }); - passwordChange.verificationCodeInput.placeholder = "Verification Code (From Email)"; - passwordChange.submitButton = passwordChange.window.button(20, 195, 260, 30, 'CHANGE PASSWORD', { main: { backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha), @@ -147,7 +127,7 @@ function passwordChangeFailed(errorMessage) { function checkChangePassword() { logToConsole(LOG_DEBUG, `[VRR.GUI] Checking password change with server ...`); - triggerNetworkEvent("vrr.checkChangePassword", passwordChange.passwordInput.lines[0], passwordChange.confirmPasswordInput.lines[0], passwordChange.verificationCodeInput.lines[0]); + sendNetworkEventToServer("vrr.checkChangePassword", passwordChange.passwordInput.lines[0], passwordChange.confirmPasswordInput.lines[0]); } // =========================================================================== diff --git a/scripts/server/account.js b/scripts/server/account.js index 25f28700..cdd69734 100644 --- a/scripts/server/account.js +++ b/scripts/server/account.js @@ -945,14 +945,15 @@ function checkAccountResetPasswordRequest(client, inputText) { return false; } - let passwordResetCode = generateEmailVerificationCode(); + let passwordResetCode = toUpperCase(generateEmailVerificationCode()); getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_CODEINPUT; getPlayerData(client).passwordResetCode = passwordResetCode; - sendPasswordResetEmail(getPlayerData(client).accountData.emailAddress, passwordResetCode); + sendPasswordResetEmail(client, passwordResetCode); + showPlayerResetPasswordCodeInputGUI(client); } else if(getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_CODEINPUT) { - if(getPlayerData(client).passwordResetCode == inputText) { + if(getPlayerData(client).passwordResetCode == toUpperCase(inputText)) { getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_SETPASS; - showChangePasswordGUI(client); + showPlayerChangePasswordGUI(client); } else { getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; client.disconnect(); @@ -964,7 +965,7 @@ function checkAccountResetPasswordRequest(client, inputText) { // =========================================================================== -function checkAccountChangePassword(client, oldPassword, newPassword, confirmNewPassword) { +function checkAccountChangePassword(client, newPassword, confirmNewPassword) { if(!isPlayerLoggedIn(client)) { if(getPlayerData(client).passwordResetState != VRR_RESETPASS_STATE_SETPASS) { //getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; @@ -973,24 +974,29 @@ function checkAccountChangePassword(client, oldPassword, newPassword, confirmNew } } - if(isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerName(client), oldPassword))) { - messagePlayerError(client, `The old password is incorrect!`); - return false; - } + //if(isAccountPasswordCorrect(getPlayerData(client).accountData, hashAccountPassword(getPlayerName(client), oldPassword))) { + // messagePlayerError(client, `The old password is incorrect!`); + // return false; + //} if(!doesPasswordMeetRequirements(newPassword)) { - messagePlayerError(client, `The new password must meet the requirements!`); - messagePlayerInfo(client, `Passwords must have at least one capital letter, one lowercase letter, and one number!`); + let passwordRequirementsString = `${needsCapitals}, ${needsNumbers}, ${needsSymbols}`; + let needsCapitals = getLocaleString(client, "PasswordNeedsCapitals", "1"); + let needsNumbers = getLocaleString(client, "PasswordNeedsNumbers", "1"); + let needsSymbols = getLocaleString(client, "PasswordNeedsSymbols", "1"); + + messagePlayerError(client, getLocaleString(client, "AccountPasswordNeedsImproved")); + messagePlayerInfo(client, getLocaleString(client, "PasswordNeedsBase", passwordRequirementsString)); return false; } if(newPassword != confirmNewPassword) { - messagePlayerError(client, `The new password and confirm new password aren't the same!`); + messagePlayerError(client, getLocaleString(client, "PasswordsDontMatch")); return false; } getPlayerData(client).accountData.password = hashAccountPassword(getPlayerData(client).accountData.name, params); - messagePlayerSuccess(client, `Your password has been changed!`); + messagePlayerSuccess(client, getLocaleString(client, "PasswordChanged")); if(getPlayerData(client).passwordResetState == VRR_RESETPASS_STATE_SETPASS) { getPlayerData(client).passwordResetState = VRR_RESETPASS_STATE_NONE; @@ -1079,12 +1085,10 @@ function initClient(client) { let sessionId = saveConnectionToDatabase(client); getServerData().clients[client.index].session = sessionId; getServerData().clients[client.index].connectTime = Math.ceil(sdl.ticks); - getServerData().clients[client.index].keyBinds = loadAccountKeybindsFromDatabase(tempAccountData.databaseId); - sendAccountKeyBindsToClient(client); if(tempAccountData != false) { if(isAccountAutoIPLoginEnabled(tempAccountData) && getPlayerData(client).accountData.ipAddress == client.ip) { - messagePlayerAlert(client, "You have been automatically logged in via IP!"); + messagePlayerAlert(client, getLocaleString(client, "AutoLoggedInIP")); loginSuccess(client); } else { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { @@ -1092,7 +1096,7 @@ function initClient(client) { showPlayerLoginGUI(client); } else { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the login message (GUI disabled).`); - messagePlayerNormal(client, `Welcome back to ${getServerName()}, ${getPlayerName(client)}! Please /login to continue.`, getColourByName("softGreen")); + messagePlayerNormal(client, getLocaleString(client, "WelcomeBack", getServerName(), getPlayerName(client)), getColourByName("softGreen")); } playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); } @@ -1102,10 +1106,13 @@ function initClient(client) { showPlayerRegistrationGUI(client); } else { logToConsole(LOG_DEBUG, `[VRR.Account] ${getPlayerDisplayForConsole(client)} is being shown the register message (GUI disabled).`); - messagePlayerNormal(client, `Welcome to ${getServerName()}, ${getPlayerName(client)}! Please /register to continue.`, getColourByName("softGreen")); + messagePlayerNormal(client, getLocaleString(client, "WelcomeNewPlayer", getServerName(), getPlayerName(client)), getColourByName("softGreen")); } playRadioStreamForPlayer(client, getServerIntroMusicURL(), true, getPlayerStreamingRadioVolume(client)); } + + getServerData().clients[client.index].keyBinds = loadAccountKeybindsFromDatabase(getServerData().clients[client.index].accountData.databaseId); + sendAccountKeyBindsToClient(client); } }, 2500); } @@ -1152,7 +1159,7 @@ function loadAccountKeybindsFromDatabase(accountDatabaseID) { tempAccountKeybinds.push(tempKeyBindData); } - if(accountDatabaseID != 0) { + if(accountDatabaseID != 0 && typeof accountDatabaseId != "undefined") { if(dbConnection) { dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID} AND acct_hotkey_server = ${getServerId()}`); if(dbQuery) {