|
1 | | -<?php |
2 | | - |
| 1 | +<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */ |
3 | 2 | namespace BNETDocs\Templates\User; |
4 | | - |
5 | 3 | use \CarlBennett\MVC\Libraries\Common; |
6 | 4 | use \CarlBennett\MVC\Libraries\Pair; |
7 | | - |
8 | | -$title = 'Reset Password'; |
| 5 | +$title = 'Reset Password'; |
9 | 6 | $description = 'This form allows an individual to reset the password to their account.'; |
10 | 7 | $this->opengraph->attach(new Pair('url', '/user/resetpassword')); |
11 | | - |
12 | | -switch ($this->getContext()->error) { |
13 | | - case 'EMPTY_EMAIL': |
14 | | - $message = 'The email address was left blank.'; |
15 | | - break; |
16 | | - case 'USER_NOT_FOUND': |
17 | | - $message = 'The email address was not found in our system.'; |
18 | | - break; |
19 | | - case 'EMAIL_FAILURE': |
20 | | - $message = 'The server failed to queue the password reset email.'; |
21 | | - break; |
22 | | - case 'INVALID_TOKEN': |
23 | | - $message = 'The token is expired or invalid and therefore cannot be used.'; |
24 | | - break; |
25 | | - case 'PASSWORD_TOO_LONG': |
26 | | - $message = 'The password is too long, shorten it.'; |
27 | | - break; |
28 | | - case 'PASSWORD_TOO_SHORT': |
29 | | - $message = 'The password is too short, use a better password.'; |
30 | | - break; |
31 | | - case 'PASSWORD_CONTAINS_EMAIL': |
32 | | - $message = 'The password contains the email address, ' |
33 | | - . 'use a better password.'; |
34 | | - break; |
35 | | - case 'PASSWORD_CONTAINS_USERNAME': |
36 | | - $message = 'The password contains the username, use a better password.'; |
37 | | - break; |
38 | | - case 'PASSWORD_MISMATCH': |
39 | | - $message = 'The passwords did not match, please try again.'; |
40 | | - break; |
41 | | - case 'USER_DISABLED': |
42 | | - $message = 'The account has been administratively disabled.'; |
43 | | - break; |
44 | | - default: |
45 | | - $message = $this->getContext()->error; |
| 8 | +$email = filter_var($this->getContext()->email, FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
| 9 | +$error = $this->getContext()->error; |
| 10 | +switch ($error) |
| 11 | +{ |
| 12 | + case 'EMPTY_EMAIL': $message = 'The email address was left blank.'; break; |
| 13 | + case 'USER_NOT_FOUND': $message = 'The email address was not found in our system.'; break; |
| 14 | + case 'EMAIL_FAILURE': $message = 'The server failed to queue the password reset email.'; break; |
| 15 | + case 'INVALID_TOKEN': $message = 'The token is expired or invalid and therefore cannot be used.'; break; |
| 16 | + case 'PASSWORD_TOO_LONG': $message = 'The password is too long, shorten it.'; break; |
| 17 | + case 'PASSWORD_TOO_SHORT': $message = 'The password is too short, use a better password.'; break; |
| 18 | + case 'PASSWORD_CONTAINS_EMAIL': $message = 'The password contains the email address, use a better password.'; break; |
| 19 | + case 'PASSWORD_CONTAINS_USERNAME': $message = 'The password contains the username, use a better password.'; break; |
| 20 | + case 'PASSWORD_MISMATCH': $message = 'The passwords did not match, please try again.'; break; |
| 21 | + case 'USER_DISABLED': $message = 'The account has been administratively disabled.'; break; |
| 22 | + default: $message = $error; |
46 | 23 | } |
47 | | - |
48 | | -require('./header.inc.phtml'); |
49 | | -?> |
50 | | - <article> |
51 | | -<?php if ($this->getContext()->error !== false) { ?> |
52 | | - <header>Reset Password</header> |
53 | | -<?php if (!empty($message)) { ?> |
54 | | - <section class="red"> |
55 | | - <p><?php echo $message; ?></p> |
56 | | - </section> |
57 | | -<?php } ?> |
58 | | - <form method="POST" action="?"> |
59 | | -<?php if (empty($this->getContext()->token)) { ?> |
60 | | - <section> |
61 | | - <label for="email">Email address:</label><br/> |
62 | | - <input |
63 | | - type="email" |
64 | | - name="email" |
65 | | - id="email" |
66 | | - value="<?=filter_var($this->getContext()->email, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>" |
67 | | - tabindex="1" |
68 | | - required |
69 | | - autocomplete="email" |
70 | | - autofocus="autofocus" |
71 | | - /> |
72 | | - </section> |
73 | | - <section> |
74 | | - <input |
75 | | - type="submit" |
76 | | - value="Reset Password" |
77 | | - tabindex="2" |
78 | | - /> |
79 | | - </section> |
80 | | -<?php } else { ?> |
81 | | - <input type="hidden" name="email" value="<?=filter_var($this->getContext()->email, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>"/> |
82 | | - <input type="hidden" name="t" value="<?=filter_var($this->getContext()->token, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>"/> |
83 | | - <section> |
84 | | - <label for="email">Email address:</label><br/> |
85 | | - <input type="email" id="email" readonly disabled tabindex="1" value="<?=filter_var($this->getContext()->email, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>"/> |
86 | | - </section> |
87 | | - <section> |
88 | | - <label for="pw1">New Password:</label><br/> |
89 | | - <input |
90 | | - type="password" |
91 | | - name="pw1" |
92 | | - id="pw1" |
93 | | - value="" |
94 | | - tabindex="2" |
95 | | - required |
96 | | - autocomplete="new-password" |
97 | | - autofocus="autofocus" |
98 | | - /> |
99 | | - </section> |
100 | | - <section> |
101 | | - <label for="pw2">Confirm Password:</label><br/> |
102 | | - <input |
103 | | - type="password" |
104 | | - name="pw2" |
105 | | - id="pw2" |
106 | | - value="" |
107 | | - tabindex="3" |
108 | | - required |
109 | | - autocomplete="new-password" |
110 | | - /> |
111 | | - </section> |
112 | | - <section> |
113 | | - <input |
114 | | - type="submit" |
115 | | - value="Change Password" |
116 | | - tabindex="4" |
117 | | - /> |
118 | | - </section> |
119 | | -<?php } ?> |
120 | | - </form> |
121 | | -<?php } else { ?> |
122 | | -<?php if (empty($this->getContext()->token)) { ?> |
123 | | - <header class="green">Email Sent</header> |
124 | | - <section class="green"> |
125 | | - <p>An email has been sent with a link to reset the password.</p> |
126 | | - <p>Use the navigation to the left to move to another page.</p> |
127 | | - </section> |
128 | | -<?php } else { ?> |
129 | | - <header class="green">Password Changed</header> |
130 | | - <section class="green"> |
131 | | - <p>Your password has been changed, you may now log in.</p> |
132 | | - <p>Use the navigation to the left to move to another page.</p> |
133 | | - </section> |
134 | | -<?php } ?> |
135 | | -<?php } ?> |
136 | | - </article> |
137 | | -<?php require('./footer.inc.phtml'); ?> |
| 24 | +require('./header.inc.phtml'); ?> |
| 25 | +<div class="container"> |
| 26 | +<? if ($this->getContext()->error !== false) { ?> |
| 27 | + <h1>Reset Password</h1> |
| 28 | +<? if (!empty($message)) { ?> |
| 29 | + <div class="alert alert-danger"> |
| 30 | + <p class="mb-0"><?=$message?></p> |
| 31 | + </div> |
| 32 | +<? } ?> |
| 33 | + <form method="POST" action="?"> |
| 34 | +<? if (empty($this->getContext()->token)) { ?> |
| 35 | + <div class="form-group"> |
| 36 | + <label class="font-weight-bold" for="email">Email address:</label> |
| 37 | + <input class="bg-dark border border-primary form-control text-light" type="email" name="email" id="email" placeholder="Enter the email address here" value="<?=$email?>" tabindex="1" required autocomplete="email" autofocus="autofocus"/> |
| 38 | + </div> |
| 39 | + <div class="form-group"> |
| 40 | + <input class="btn btn-success" type="submit" value="Reset Password" tabindex="2"/> |
| 41 | + </div> |
| 42 | +<? } else { ?> |
| 43 | + <input type="hidden" name="email" value="<?=$email?>"/> |
| 44 | + <input type="hidden" name="t" value="<?=filter_var($this->getContext()->token, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>"/> |
| 45 | + <div class="form-group"> |
| 46 | + <label class="font-weight-bold" for="email">Email address:</label><br/> |
| 47 | + <p class="border border-primary p-2"><?=$email?></p> |
| 48 | + </div> |
| 49 | + <div class="form-group"> |
| 50 | + <label class="font-weight-bold" for="pw1">New Password:</label><br/> |
| 51 | + <input class="bg-dark border border-primary form-control text-light" type="password" name="pw1" id="pw1" placeholder="Enter the new password here" value="" tabindex="2" required autocomplete="new-password" autofocus="autofocus"/> |
| 52 | + </div> |
| 53 | + <div class="form-group"> |
| 54 | + <label class="font-weight-bold" for="pw2">Confirm Password:</label><br/> |
| 55 | + <input class="bg-dark border border-primary form-control text-light" type="password" name="pw2" id="pw2" placeholder="Confirm the new password here" value="" tabindex="3" required autocomplete="new-password"/> |
| 56 | + </div> |
| 57 | + <div class="form-group"> |
| 58 | + <input class="btn btn-success" type="submit" value="Change Password" tabindex="4"/> |
| 59 | + </section> |
| 60 | +<? } ?> |
| 61 | + </form> |
| 62 | +<? } else { ?> |
| 63 | +<? if (empty($this->getContext()->token)) { ?> |
| 64 | + <h1 class="text-success">Email Sent</h1> |
| 65 | + <div class="alert alert-success"> |
| 66 | + <p class="mb-0">An email has been sent with a link to reset the password.</p> |
| 67 | + </div> |
| 68 | +<? } else { ?> |
| 69 | + <h1 class="text-success">Password Changed</h1> |
| 70 | + <div class="alert alert-success"> |
| 71 | + <p class="mb-0">Your password has been changed, you may now log in.</p> |
| 72 | + </div> |
| 73 | +<? } ?> |
| 74 | +<? } ?> |
| 75 | +</div> |
| 76 | +<? require('./footer.inc.phtml'); ?> |
0 commit comments