[aur-dev] [PATCH 1/2] passreset.php: Refactor HTML
* Use the "errorlist" class for errors. * Refactor some code. * Properly display error messages when requesting a key. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/passreset.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/web/html/passreset.php b/web/html/passreset.php index 94a1ad9..59fd4bc 100644 --- a/web/html/passreset.php +++ b/web/html/passreset.php @@ -56,16 +56,14 @@ html_header(__("Password Reset")); <div class="box"> <h2><?= __("Password Reset"); ?></h2> + <?php if ($step == 'confirm'): ?> + <p>Check your e-mail for the confirmation link.</p> + <?php elseif ($step == 'complete'): ?> + <p>Your password has been reset successfully.</p> + <?php elseif (isset($_GET['resetkey'])): ?> <?php if ($error): ?> - <p><span class="error"><?= $error ?></span></p> - <?php endif;?> - <?php - if ($step == 'confirm') { - echo __('Check your e-mail for the confirmation link.'); - } elseif ($step == 'complete') { - echo __('Your password has been reset successfully.'); - } elseif (isset($_GET['resetkey'])) { - ?> + <ul class="errorlist"><li><?= $error ?></li></ul> + <?php endif; ?> <form action="" method="post"> <table> <tr> @@ -84,18 +82,19 @@ html_header(__("Password Reset")); <br /> <input type="submit" class="button" value="<?= __('Continue') ?>" /> </form> - <?php - } else { - ?> + <?php else: ?> <p><?= __('If you have forgotten the e-mail address you used to register, please send a message to the %saur-general%s mailing list.', '<a href="https://mailman.archlinux.org/mailman/listinfo/aur-general">', '</a>'); ?></p> + <?php if ($error): ?> + <ul class="errorlist"><li><?= $error ?></li></ul> + <?php endif; ?> <form action="" method="post"> <p><?= __("Enter your e-mail address:"); ?> <input type="text" name="email" size="30" maxlength="64" /></p> <input type="submit" class="button" value="<?= __('Continue') ?>" /> </form> - <?php } ?> + <?php endif; ?> </div> <?php -- 1.8.5.2
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/html/passreset.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/web/html/passreset.php b/web/html/passreset.php index 59fd4bc..e926161 100644 --- a/web/html/passreset.php +++ b/web/html/passreset.php @@ -37,14 +37,19 @@ if (isset($_GET['resetkey'], $_POST['email'], $_POST['password'], $_POST['confir } } elseif (isset($_POST['email'])) { $email = $_POST['email']; - $body = __('A password reset request was submitted for the account '. - 'associated with your e-mail address. If you wish to reset '. - 'your password follow the link below, otherwise ignore '. - 'this message and nothing will happen.'). - send_resetkey($email, $body); - header('Location: ' . get_uri('/passreset/') . '?step=confirm'); - exit(); + if (empty($email)) { + $error = __('Missing a required field.'); + } else { + $body = __('A password reset request was submitted for the account '. + 'associated with your e-mail address. If you wish to reset '. + 'your password follow the link below, otherwise ignore '. + 'this message and nothing will happen.'). + send_resetkey($email, $body); + + header('Location: ' . get_uri('/passreset/') . '?step=confirm'); + exit(); + } } $step = isset($_GET['step']) ? $_GET['step'] : NULL; -- 1.8.5.2
participants (1)
-
Lukas Fleischer