Skip to content

Commit

Permalink
System: improve password reset error messages, remove unsaved changes…
Browse files Browse the repository at this point in the history
… warning
  • Loading branch information
SKuipers committed Nov 11, 2024
1 parent 4ee8933 commit aae42bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 16 additions & 11 deletions passwordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@

$page->breadcrumbs->add(__('Password Reset'));

$page->return->addReturns([
'error0' => __('Email address not set.'),
'error4' => __('Your request failed due to incorrect, non-existent or non-unique email address or username.'),
'error3' => __('Email failed to send to {email}', ['email' => $_GET['email'] ?? '']),
'error5' => __('Your request failed due to non-matching passwords.'),
'error6' => __('Your request failed because your password does not meet the minimum requirements for strength.'),
'error7' => __('Your request failed because your new password is the same as your current password.'),
'fail2' => __('You do not have sufficient privileges to login.'),
'fail9' => __('Your primary role does not support the ability to log into the specified year.'),
'success0' => __('Password reset request successfully initiated, please check your email.'),
]);

$step = 1;
if (isset($_GET['step']) and $_GET['step'] == 2) {
$step = 2;
Expand All @@ -36,19 +48,10 @@
<?php echo sprintf(__('Enter your %1$s username, or the email address you have listed in the system, and press submit: a unique password reset link will be emailed to you.'), $session->get('systemName')); ?>
</p>
<?php
$returns = array();
$returns['error0'] = __('Email address not set.');
$returns['error4'] = __('Your request failed due to incorrect, non-existent or non-unique email address or username.');
$returns['error3'] = __('Failed to send update email.');
$returns['error5'] = __('Your request failed due to non-matching passwords.');
$returns['error6'] = __('Your request failed because your password does not meet the minimum requirements for strength.');
$returns['error7'] = __('Your request failed because your new password is the same as your current password.');
$returns['fail2'] = __('You do not have sufficient privileges to login.');
$returns['fail9'] = __('Your primary role does not support the ability to log into the specified year.');
$returns['success0'] = __('Password reset request successfully initiated, please check your email.');
$page->return->addReturns($returns);


$form = Form::create('action', $session->get('absoluteURL').'/passwordResetProcess.php?step=1');
$form->addClass('disable-warnings');

$form->addHiddenValue('address', $session->get('address'));

Expand Down Expand Up @@ -88,6 +91,8 @@
echo '</div>';

$form = Form::create('action', $session->get('absoluteURL').'/passwordResetProcess.php?'.http_build_query($urlParams));
$form->addClass('disable-warnings');

$form->addHiddenValue('address', $session->get('address'));

$form->addRow()->addHeading('Reset Password', __('Reset Password'));
Expand Down
4 changes: 2 additions & 2 deletions passwordResetProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
$input = filter_var(trim($input), FILTER_SANITIZE_EMAIL);
$step = $_GET['step'] ?? '';

$URL = Url::fromRoute('passwordReset');
$URL = Url::fromRoute('passwordReset')->withQueryParam('email', $input);
$URLSuccess1 = Url::fromRoute();

if ($input == '' or ($step != 1 and $step != 2)) {
Expand All @@ -62,7 +62,7 @@
}

if ($result->rowCount() != 1) {
header("Location: {$URL->withReturn('error0')}");
header("Location: {$URL->withReturn('error4')}");
exit();
} else {
$row = $result->fetch();
Expand Down

0 comments on commit aae42bf

Please sign in to comment.