|
1 |
| -<?php |
2 |
| - |
| 1 | +<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */ |
3 | 2 | namespace BNETDocs\Templates\User;
|
4 |
| - |
| 3 | +use \CarlBennett\MVC\Libraries\Common; |
5 | 4 | use \CarlBennett\MVC\Libraries\Pair;
|
6 |
| - |
7 |
| -$title = "Change Password"; |
8 |
| -$description = "This form allows an individual to change the password to their account."; |
9 |
| -$this->opengraph->attach(new Pair("url", "/user/changepassword")); |
10 |
| - |
11 |
| -switch ($this->getContext()->error) { |
12 |
| - case "NOT_LOGGED_IN": |
13 |
| - $message = "You were not logged in to begin with."; |
14 |
| - break; |
15 |
| - case "NONMATCHING_PASSWORD": |
16 |
| - $message = "The new password does not match its confirmation."; |
17 |
| - break; |
18 |
| - case "PASSWORD_CONTAINS_EMAIL": |
19 |
| - $message = "The password contains the email address, " |
20 |
| - . "use a better password."; |
21 |
| - break; |
22 |
| - case "PASSWORD_CONTAINS_USERNAME": |
23 |
| - $message = "The password contains the username, use a better password."; |
24 |
| - break; |
25 |
| - case "PASSWORD_INCORRECT": |
26 |
| - $message = "You did not enter your correct current password."; |
27 |
| - break; |
28 |
| - case "PASSWORD_TOO_LONG": |
29 |
| - $message = "The password is too long, shorten it."; |
30 |
| - break; |
31 |
| - case "PASSWORD_TOO_SHORT": |
32 |
| - $message = "The password is too short, use a better password."; |
33 |
| - break; |
34 |
| - case "PASSWORD_BLACKLIST": |
35 |
| - $message = $this->getContext()->error_extra; |
36 |
| - if (empty($message)) $message = "The new password is blacklisted."; |
37 |
| - break; |
38 |
| - case "INTERNAL_ERROR": |
39 |
| - $message = "An internal error occurred while processing your request. " |
40 |
| - . "Our staff have been notified of the issue. Try again later."; |
41 |
| - break; |
42 |
| - default: |
43 |
| - $message = $this->getContext()->error; |
| 5 | +$title = 'Change Password'; |
| 6 | +$description = 'This form allows an individual to change the password to their account.'; |
| 7 | +$this->opengraph->attach(new Pair('url', '/user/changepassword')); |
| 8 | +$error = $this->getContext()->error; |
| 9 | +switch ($error) |
| 10 | +{ |
| 11 | + case 'NOT_LOGGED_IN': $message = 'You were not logged in to begin with.'; break; |
| 12 | + case 'NONMATCHING_PASSWORD': $message = 'The new password does not match its confirmation.'; break; |
| 13 | + case 'PASSWORD_CONTAINS_EMAIL': $message = 'The password contains the email address, use a better password.'; break; |
| 14 | + case 'PASSWORD_CONTAINS_USERNAME': $message = 'The password contains the username, use a better password.'; break; |
| 15 | + case 'PASSWORD_INCORRECT': $message = 'You did not enter your correct current password.'; 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_BLACKLIST': $message = $this->getContext()->error_extra; if (empty($message)) $message = 'The new password is blacklisted.'; break; |
| 19 | + case 'INTERNAL_ERROR': $message = 'An internal error occurred while processing your request. Our staff have been notified of the issue. Try again later.'; break; |
| 20 | + default: $message = $error; |
44 | 21 | }
|
45 |
| - |
46 |
| -require("./header.inc.phtml"); |
47 |
| -?> |
48 |
| - <article> |
49 |
| -<?php if ($this->getContext()->error !== false) { ?> |
50 |
| - <header>Change Password</header> |
51 |
| -<?php if (!empty($message)) { ?> |
52 |
| - <section class="red"> |
53 |
| - <p><?php echo $message; ?></p> |
54 |
| - </section> |
55 |
| -<?php } ?> |
56 |
| - <form method="POST" action="?"> |
57 |
| - <section> |
58 |
| - <table><tbody><tr> |
59 |
| - <td colspan="2"> |
60 |
| - <label for="pw1">Current password:</label><br/> |
61 |
| - <input type="password" name="pw1" id="pw1" tabindex="1" |
62 |
| - value="" required autofocus="autofocus"/> |
63 |
| - </td></tr><tr><td> |
64 |
| - <label for="pw2">New password:</label><br/> |
65 |
| - <input type="password" name="pw2" id="pw2" tabindex="2" |
66 |
| - value="" required/> |
67 |
| - </td><td> |
68 |
| - <label for="pw3">Confirm password:</label><br/> |
69 |
| - <input type="password" name="pw3" id="pw3" tabindex="3" |
70 |
| - value="" required/> |
71 |
| - </td></tr><tr><td colspan="2" style="padding-top:16px;"> |
72 |
| - <input type="submit" value="Submit" tabindex="4"/> |
73 |
| - </td> |
74 |
| - </tr></tbody></table> |
75 |
| - </section> |
76 |
| - </form> |
77 |
| -<?php } else { ?> |
78 |
| - <header class="green">Password Changed</header> |
79 |
| - <section class="green"> |
80 |
| - <p>You have successfully changed your password!</p> |
81 |
| - <p>Use the navigation to the left to move to another page.</p> |
82 |
| - </section> |
83 |
| -<?php } ?> |
84 |
| - </article> |
85 |
| -<?php require("./footer.inc.phtml"); ?> |
| 22 | +require('./header.inc.phtml'); ?> |
| 23 | +<div class="container mb-3"> |
| 24 | + <div class="card mx-auto mb-3" style="width:18rem;"> |
| 25 | + <h3 class="card-header text-lg-center"><?=$title?></h3> |
| 26 | + <div class="card-body"> |
| 27 | +<? if ($error !== false) { ?> |
| 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 | + <div class="form-group"> |
| 35 | + <label class="form-input-label" for="pw1">Current password:</label> |
| 36 | + <input class="form-control border border-secondary bg-dark text-light" type="password" name="pw1" id="pw1" tabindex="1" value="" required autofocus="autofocus"/> |
| 37 | + </div> |
| 38 | + <div class="form-group"> |
| 39 | + <label class="form-input-label" for="pw2">New password:</label><br/> |
| 40 | + <input class="form-control border border-secondary bg-dark text-light" type="password" name="pw2" id="pw2" tabindex="2" value="" required/> |
| 41 | + </div> |
| 42 | + <div class="form-group"> |
| 43 | + <label class="form-input-label" for="pw3">Confirm password:</label><br/> |
| 44 | + <input class="form-control border border-secondary bg-dark text-light" type="password" name="pw3" id="pw3" tabindex="3" value="" required/> |
| 45 | + </div> |
| 46 | + <div class="form-group text-center"> |
| 47 | + <hr class="border-secondary w-25"/> |
| 48 | + <input class="btn btn-success" type="submit" value="Change Password" tabindex="4"/> |
| 49 | + </div> |
| 50 | + </form> |
| 51 | +<? } else { ?> |
| 52 | + <div class="alert alert-success"> |
| 53 | + <h4 class="alert-header">Password Changed</h4> |
| 54 | + <p class="mb-0">You have successfully changed your password!</p> |
| 55 | + </div> |
| 56 | +<? } ?> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + <div class="text-center"> |
| 60 | + <a class="btn btn-primary" href="<?=Common::relativeUrlToAbsolute('/user/update')?>"><img class="float-left" src="<?=Common::relativeUrlToAbsolute('/a/svg/chevron-right-white.svg' . $_unique_asset)?>"/> Return to Update Profile</a> |
| 61 | + </div> |
| 62 | +</div> |
| 63 | +<? require('./footer.inc.phtml'); ?> |
0 commit comments