Port notification routines to Python
[aur.git] / web / html / passreset.php
blobcb2f6bcddb5309f6f83591370de8c6c893955338
1 <?php
3 set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
5 include_once("aur.inc.php"); # access AUR common functions
7 set_lang(); # this sets up the visitor's language
8 check_sid(); # see if they're still logged in
10 if (isset($_COOKIE["AURSID"])) {
11 header('Location: /');
12 exit();
15 $error = '';
17 if (isset($_GET['resetkey'], $_POST['email'], $_POST['password'], $_POST['confirm'])) {
18 $resetkey = $_GET['resetkey'];
19 $email = $_POST['email'];
20 $password = $_POST['password'];
21 $confirm = $_POST['confirm'];
22 $uid = uid_from_email($email);
24 if (empty($email) || empty($password)) {
25 $error = __('Missing a required field.');
26 } elseif ($password != $confirm) {
27 $error = __('Password fields do not match.');
28 } elseif (!good_passwd($password)) {
29 $length_min = config_get_int('options', 'passwd_min_len');
30 $error = __("Your password must be at least %s characters.",
31 $length_min);
32 } elseif ($uid == null) {
33 $error = __('Invalid e-mail.');
36 if (empty($error)) {
37 $salt = generate_salt();
38 $hash = salted_hash($password, $salt);
40 $error = password_reset($hash, $salt, $resetkey, $email);
42 } elseif (isset($_POST['email'])) {
43 $email = $_POST['email'];
44 $username = username_from_id(uid_from_email($email));
46 if (empty($email)) {
47 $error = __('Missing a required field.');
48 } else {
49 send_resetkey($email);
50 header('Location: ' . get_uri('/passreset/') . '?step=confirm');
51 exit();
55 $step = isset($_GET['step']) ? $_GET['step'] : NULL;
57 html_header(__("Password Reset"));
61 <div class="box">
62 <h2><?= __("Password Reset"); ?></h2>
64 <?php if ($step == 'confirm'): ?>
65 <p><?= __('Check your e-mail for the confirmation link.') ?></p>
66 <?php elseif ($step == 'complete'): ?>
67 <p><?= __('Your password has been reset successfully.') ?></p>
68 <?php elseif (isset($_GET['resetkey'])): ?>
69 <?php if ($error): ?>
70 <ul class="errorlist"><li><?= $error ?></li></ul>
71 <?php endif; ?>
72 <form action="" method="post">
73 <table>
74 <tr>
75 <td><?= __("Confirm your e-mail address:"); ?></td>
76 <td><input type="text" name="email" size="30" maxlength="64" /></td>
77 </tr>
78 <tr>
79 <td><?= __("Enter your new password:"); ?></td>
80 <td><input type="password" name="password" size="30" /></td>
81 </tr>
82 <tr>
83 <td><?= __("Confirm your new password:"); ?></td>
84 <td><input type="password" name="confirm" size="30" /></td>
85 </tr>
86 </table>
87 <br />
88 <input type="submit" class="button" value="<?= __('Continue') ?>" />
89 </form>
90 <?php else: ?>
91 <p><?= __('If you have forgotten the e-mail address you used to register, please send a message to the %saur-general%s mailing list.',
92 '<a href="https://mailman.archlinux.org/mailman/listinfo/aur-general">',
93 '</a>'); ?></p>
94 <?php if ($error): ?>
95 <ul class="errorlist"><li><?= $error ?></li></ul>
96 <?php endif; ?>
97 <form action="" method="post">
98 <p><?= __("Enter your e-mail address:"); ?>
99 <input type="text" name="email" size="30" maxlength="64" /></p>
100 <input type="submit" class="button" value="<?= __('Continue') ?>" />
101 </form>
102 <?php endif; ?>
103 </div>
105 <?php
107 html_footer(AURWEB_VERSION);