fix: password2 variable refactor to correct name (#237)

This commit is contained in:
Kamil Grzechulski 2023-10-06 07:52:21 +02:00 committed by GitHub
parent 3b9feaf3bd
commit 26a80e0741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 29 deletions

View File

@ -14,7 +14,7 @@ describe('Create Account Page', () => {
cy.get('#email').type('tester@example.com') cy.get('#email').type('tester@example.com')
cy.get('#password').type('test1234') cy.get('#password').type('test1234')
cy.get('#password2').type('test1234') cy.get('#password_confirm').type('test1234')
cy.get('#character_name').type('Slaw') cy.get('#character_name').type('Slaw')

View File

@ -18,18 +18,18 @@ if(!$logged) {
} }
$new_password = $_POST['newpassword'] ?? NULL; $new_password = $_POST['newpassword'] ?? NULL;
$new_password2 = $_POST['newpassword2'] ?? NULL; $new_password_confirm = $_POST['newpassword_confirm'] ?? NULL;
$old_password = $_POST['oldpassword'] ?? 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'); $twig->display('account.change_password.html.twig');
} }
else 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.'; $errors[] = 'Please fill in form.';
} }
$password_strlen = strlen($new_password); $password_strlen = strlen($new_password);
if($new_password != $new_password2) { if($new_password != $new_password_confirm) {
$errors[] = 'The new passwords do not match!'; $errors[] = 'The new passwords do not match!';
} }

View File

@ -50,7 +50,7 @@ if($save)
$email = $_POST['email']; $email = $_POST['email'];
$password = $_POST['password']; $password = $_POST['password'];
$password2 = $_POST['password2']; $password_confirm = $_POST['password_confirm'];
// account // account
if(!config('account_login_by_email')) { if(!config('account_login_by_email')) {
@ -81,7 +81,7 @@ if($save)
if(empty($password)) { if(empty($password)) {
$errors['password'] = 'Please enter the password for your new account.'; $errors['password'] = 'Please enter the password for your new account.';
} }
elseif($password != $password2) { elseif($password != $password_confirm) {
$errors['password'] = 'Passwords are not the same.'; $errors['password'] = 'Passwords are not the same.';
} }
else if(!Validator::password($password)) { else if(!Validator::password($password)) {
@ -134,7 +134,7 @@ if($save)
'email' => $email, 'email' => $email,
'country' => $country, 'country' => $country,
'password' => $password, 'password' => $password,
'password2' => $password2, 'password_confirm' => $password_confirm,
'accept_rules' => isset($_POST['accept_rules']) ? $_POST['accept_rules'] === 'true' : false, '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['account_login'] = USE_ACCOUNT_NAME ? $account_name : $account_id;
} }
$_POST['password_login'] = $password2; $_POST['password_login'] = $password_confirm;
require PAGES . 'account/login.php'; require PAGES . 'account/login.php';
header('Location: ' . getLink('account/manage')); header('Location: ' . getLink('account/manage'));

View File

@ -33,7 +33,7 @@ Please enter your current password and a new password. For your security, please
<span>New Password Again:</span> <span>New Password Again:</span>
</td> </td>
<td> <td>
<input type="password" name="newpassword2" size="30" maxlength="29"> <input type="password" name="newpassword_confirm" size="30" maxlength="29">
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -104,11 +104,11 @@
<span{% if errors.password is defined %} class="red"{% endif %}>Repeat password:</span> <span{% if errors.password is defined %} class="red"{% endif %}>Repeat password:</span>
</td> </td>
<td> <td>
<input type="password" name="password2" id="password2" value="" size="30" maxlength="29" /> <input type="password" name="password_confirm" id="password_confirm" value="" size="30" maxlength="29" />
<img id="password2_indicator" src="images/global/general/{% if not save or errors.password is defined %}n{% endif %}ok.gif" style="display: none;" /> <img id="password_confirm_indicator" src="images/global/general/{% if not save or errors.password is defined %}n{% endif %}ok.gif" style="display: none;" />
</td> </td>
</tr> </tr>
<tr><td></td><td><span id="password2_error" class="FormFieldError">{% if errors.password is defined %}{{ errors.password }}{% endif %}</span></td></tr> <tr><td></td><td><span id="password_confirm_error" class="FormFieldError">{% if errors.password is defined %}{{ errors.password }}{% endif %}</span></td></tr>
{{ hook('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS') }} {{ hook('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS') }}
</tbody> </tbody>

View File

@ -17,7 +17,7 @@
$('#password').blur(function() { $('#password').blur(function() {
checkPassword(); checkPassword();
}); });
$('#password2').blur(function() { $('#password_confirm').blur(function() {
checkPassword(); checkPassword();
}); });
$('#SuggestAccountNumber a').click(function (event) { $('#SuggestAccountNumber a').click(function (event) {
@ -150,11 +150,11 @@
return; return;
} }
if(document.getElementById("password2").value == "") if(document.getElementById("password_confirm").value == "")
{ {
$('#password2_error').html('Please enter the password again!'); $('#password_confirm_error').html('Please enter the password again!');
$('#password2_indicator').attr('src', 'images/global/general/nok.gif'); $('#password_confirm_indicator').attr('src', 'images/global/general/nok.gif');
$('#password2_indicator').show(); $('#password_confirm_indicator').show();
return; return;
} }
@ -172,24 +172,24 @@
} }
var password = document.getElementById("password").value; var password = document.getElementById("password").value;
var password2 = document.getElementById("password2").value; var password_confirm = document.getElementById("password_confirm").value;
$.getJSON("tools/validate.php", { password: password, password2: password2, uid: Math.random() }, $.getJSON("tools/validate.php", { password: password, password_confirm: password_confirm, uid: Math.random() },
function(data){ function(data){
if(data.hasOwnProperty('success')) { if(data.hasOwnProperty('success')) {
$('#password_error').html (''); $('#password_error').html ('');
$('#password2_error').html (''); $('#password_confirm_error').html ('');
$('#password_indicator').attr('src', 'images/global/general/ok.gif'); $('#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')) { else if(data.hasOwnProperty('error')) {
$('#password_error').html(data.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'); $('#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(); $('#password_indicator').show();
$('#password2_indicator').show(); $('#password_confirm_indicator').show();
} }
); );

View File

@ -75,9 +75,9 @@ else if(isset($_GET['name']))
success_('Good. Your name will be:<br /><b>' . (admin() ? $name : ucwords($name)) . '</b>'); success_('Good. Your name will be:<br /><b>' . (admin() ? $name : ucwords($name)) . '</b>');
} }
else if(isset($_GET['password']) && isset($_GET['password2'])) { else if(isset($_GET['password']) && isset($_GET['password_confirm'])) {
$password = $_GET['password']; $password = $_GET['password'];
$password2 = $_GET['password2']; $password_confirm = $_GET['password_confirm'];
if(!isset($password[0])) { if(!isset($password[0])) {
error_('Please enter the password for your new account.'); 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)) if(!Validator::password($password))
error_(Validator::getLastError()); error_(Validator::getLastError());
if($password != $password2) if($password != $password_confirm)
error_('Passwords are not the same.'); error_('Passwords are not the same.');
success_(1); success_(1);