From 26a80e074188ce23ecffcb36433ee6777f8db188 Mon Sep 17 00:00:00 2001 From: Kamil Grzechulski Date: Fri, 6 Oct 2023 07:52:21 +0200 Subject: [PATCH] fix: password2 variable refactor to correct name (#237) --- cypress/e2e/2-create-account.cy.js | 2 +- system/pages/account/change_password.php | 8 +++---- system/pages/account/create.php | 8 +++---- .../account.change_password.html.twig | 4 ++-- system/templates/account.create.html.twig | 6 ++--- system/templates/account.create.js.html.twig | 24 +++++++++---------- tools/validate.php | 6 ++--- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cypress/e2e/2-create-account.cy.js b/cypress/e2e/2-create-account.cy.js index 9fc95cb0..2ee53d5d 100644 --- a/cypress/e2e/2-create-account.cy.js +++ b/cypress/e2e/2-create-account.cy.js @@ -14,7 +14,7 @@ describe('Create Account Page', () => { cy.get('#email').type('tester@example.com') cy.get('#password').type('test1234') - cy.get('#password2').type('test1234') + cy.get('#password_confirm').type('test1234') cy.get('#character_name').type('Slaw') diff --git a/system/pages/account/change_password.php b/system/pages/account/change_password.php index 95e15159..309c8dee 100644 --- a/system/pages/account/change_password.php +++ b/system/pages/account/change_password.php @@ -18,18 +18,18 @@ if(!$logged) { } $new_password = $_POST['newpassword'] ?? NULL; -$new_password2 = $_POST['newpassword2'] ?? NULL; +$new_password_confirm = $_POST['newpassword_confirm'] ?? NULL; $old_password = $_POST['oldpassword'] ?? NULL; -if(empty($new_password) && empty($new_password2) && empty($old_password)) { +if(empty($new_password) && empty($new_password_confirm) && empty($old_password)) { $twig->display('account.change_password.html.twig'); } else { - if(empty($new_password) || empty($new_password2) || empty($old_password)){ + if(empty($new_password) || empty($new_password_confirm) || empty($old_password)){ $errors[] = 'Please fill in form.'; } $password_strlen = strlen($new_password); - if($new_password != $new_password2) { + if($new_password != $new_password_confirm) { $errors[] = 'The new passwords do not match!'; } diff --git a/system/pages/account/create.php b/system/pages/account/create.php index 5775855f..0f190bb6 100644 --- a/system/pages/account/create.php +++ b/system/pages/account/create.php @@ -50,7 +50,7 @@ if($save) $email = $_POST['email']; $password = $_POST['password']; - $password2 = $_POST['password2']; + $password_confirm = $_POST['password_confirm']; // account if(!config('account_login_by_email')) { @@ -81,7 +81,7 @@ if($save) if(empty($password)) { $errors['password'] = 'Please enter the password for your new account.'; } - elseif($password != $password2) { + elseif($password != $password_confirm) { $errors['password'] = 'Passwords are not the same.'; } else if(!Validator::password($password)) { @@ -134,7 +134,7 @@ if($save) 'email' => $email, 'country' => $country, 'password' => $password, - 'password2' => $password2, + 'password_confirm' => $password_confirm, 'accept_rules' => isset($_POST['accept_rules']) ? $_POST['accept_rules'] === 'true' : false, ); @@ -267,7 +267,7 @@ if($save) $_POST['account_login'] = USE_ACCOUNT_NAME ? $account_name : $account_id; } - $_POST['password_login'] = $password2; + $_POST['password_login'] = $password_confirm; require PAGES . 'account/login.php'; header('Location: ' . getLink('account/manage')); diff --git a/system/templates/account.change_password.html.twig b/system/templates/account.change_password.html.twig index d801a733..bb0d7823 100644 --- a/system/templates/account.change_password.html.twig +++ b/system/templates/account.change_password.html.twig @@ -33,7 +33,7 @@ Please enter your current password and a new password. For your security, please New Password Again: - + @@ -75,4 +75,4 @@ Please enter your current password and a new password. For your security, please - \ No newline at end of file + diff --git a/system/templates/account.create.html.twig b/system/templates/account.create.html.twig index 5f9ea910..4563154b 100644 --- a/system/templates/account.create.html.twig +++ b/system/templates/account.create.html.twig @@ -104,11 +104,11 @@ Repeat password: - - + + - {% if errors.password is defined %}{{ errors.password }}{% endif %} + {% if errors.password is defined %}{{ errors.password }}{% endif %} {{ hook('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS') }} diff --git a/system/templates/account.create.js.html.twig b/system/templates/account.create.js.html.twig index 74bfb8bf..61300039 100644 --- a/system/templates/account.create.js.html.twig +++ b/system/templates/account.create.js.html.twig @@ -17,7 +17,7 @@ $('#password').blur(function() { checkPassword(); }); - $('#password2').blur(function() { + $('#password_confirm').blur(function() { checkPassword(); }); $('#SuggestAccountNumber a').click(function (event) { @@ -150,11 +150,11 @@ return; } - if(document.getElementById("password2").value == "") + if(document.getElementById("password_confirm").value == "") { - $('#password2_error').html('Please enter the password again!'); - $('#password2_indicator').attr('src', 'images/global/general/nok.gif'); - $('#password2_indicator').show(); + $('#password_confirm_error').html('Please enter the password again!'); + $('#password_confirm_indicator').attr('src', 'images/global/general/nok.gif'); + $('#password_confirm_indicator').show(); return; } @@ -172,24 +172,24 @@ } var password = document.getElementById("password").value; - var password2 = document.getElementById("password2").value; - $.getJSON("tools/validate.php", { password: password, password2: password2, uid: Math.random() }, + var password_confirm = document.getElementById("password_confirm").value; + $.getJSON("tools/validate.php", { password: password, password_confirm: password_confirm, uid: Math.random() }, function(data){ if(data.hasOwnProperty('success')) { $('#password_error').html (''); - $('#password2_error').html (''); + $('#password_confirm_error').html (''); $('#password_indicator').attr('src', 'images/global/general/ok.gif'); - $('#password2_indicator').attr('src', 'images/global/general/ok.gif'); + $('#password_confirm_indicator').attr('src', 'images/global/general/ok.gif'); } else if(data.hasOwnProperty('error')) { $('#password_error').html(data.error); - $('#password2_error').html(data.error); + $('#password_confirm_error').html(data.error); $('#password_indicator').attr('src', 'images/global/general/nok.gif'); - $('#password2_indicator').attr('src', 'images/global/general/nok.gif'); + $('#password_confirm_indicator').attr('src', 'images/global/general/nok.gif'); } $('#password_indicator').show(); - $('#password2_indicator').show(); + $('#password_confirm_indicator').show(); } ); diff --git a/tools/validate.php b/tools/validate.php index 43c965d0..78140085 100644 --- a/tools/validate.php +++ b/tools/validate.php @@ -75,9 +75,9 @@ else if(isset($_GET['name'])) success_('Good. Your name will be:
' . (admin() ? $name : ucwords($name)) . ''); } -else if(isset($_GET['password']) && isset($_GET['password2'])) { +else if(isset($_GET['password']) && isset($_GET['password_confirm'])) { $password = $_GET['password']; - $password2 = $_GET['password2']; + $password_confirm = $_GET['password_confirm']; if(!isset($password[0])) { error_('Please enter the password for your new account.'); @@ -86,7 +86,7 @@ else if(isset($_GET['password']) && isset($_GET['password2'])) { if(!Validator::password($password)) error_(Validator::getLastError()); - if($password != $password2) + if($password != $password_confirm) error_('Passwords are not the same.'); success_(1);