mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-19 12:13:25 +02:00
account/change-password refactor a bit
Add "The old password is same as the new password!" Better post variables names
This commit is contained in:
@@ -19,18 +19,17 @@ if(!$logged) {
|
|||||||
|
|
||||||
csrfProtect();
|
csrfProtect();
|
||||||
|
|
||||||
$new_password = $_POST['newpassword'] ?? NULL;
|
$new_password = $_POST['new_password'] ?? null;
|
||||||
$new_password_confirm = $_POST['newpassword_confirm'] ?? NULL;
|
$new_password_confirm = $_POST['new_password_confirm'] ?? null;
|
||||||
$old_password = $_POST['oldpassword'] ?? NULL;
|
$old_password = $_POST['old_password'] ?? null;
|
||||||
if(empty($new_password) && empty($new_password_confirm) && 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_password_confirm) || 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);
|
|
||||||
if($new_password != $new_password_confirm) {
|
if($new_password != $new_password_confirm) {
|
||||||
$errors[] = 'The new passwords do not match!';
|
$errors[] = 'The new passwords do not match!';
|
||||||
}
|
}
|
||||||
@@ -41,10 +40,13 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var OTS_Account $account_logged */
|
/** @var OTS_Account $account_logged */
|
||||||
$old_password = encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $old_password);
|
$old_password_hashed = encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $old_password);
|
||||||
if($old_password != $account_logged->getPassword()) {
|
if($old_password_hashed != $account_logged->getPassword()) {
|
||||||
$errors[] = 'Current password is incorrect!';
|
$errors[] = 'Current password is incorrect!';
|
||||||
}
|
}
|
||||||
|
else if ($old_password == $new_password) {
|
||||||
|
$errors[] = 'The old password is same as the new password!';
|
||||||
|
}
|
||||||
|
|
||||||
$hooks->trigger(HOOK_ACCOUNT_CHANGE_PASSWORD_POST);
|
$hooks->trigger(HOOK_ACCOUNT_CHANGE_PASSWORD_POST);
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ Please enter your current password and a new password. For your security, please
|
|||||||
<span>Current Password:</span>
|
<span>Current Password:</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input form="form" type="password" name="oldpassword" size="30" maxlength="29">
|
<input form="form" type="password" id="old_password" name="old_password" size="30" maxlength="29">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ Please enter your current password and a new password. For your security, please
|
|||||||
<span>New Password:</span>
|
<span>New Password:</span>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:90%;">
|
<td style="width:90%;">
|
||||||
<input form="form" type="password" name="newpassword" size="30" maxlength="29">
|
<input form="form" type="password" id="new_password" name="new_password" size="30" maxlength="29">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -31,7 +31,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 form="form" type="password" name="newpassword_confirm" size="30" maxlength="29">
|
<input form="form" type="password" id="new_password_confirm" name="new_password_confirm" size="30" maxlength="29">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Reference in New Issue
Block a user