|
1 | | -<?php namespace BNETDocs\Templates\User; |
2 | | - |
| 1 | +<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */ |
| 2 | +namespace BNETDocs\Templates\User; |
3 | 3 | use \CarlBennett\MVC\Libraries\Common; |
4 | 4 | use \CarlBennett\MVC\Libraries\Pair; |
5 | | - |
6 | | -$title = "Account Login"; |
7 | | -$description = "This form allows an individual to log in to their account on BNETDocs"; |
8 | | -$this->opengraph->attach(new Pair("url", "/user/login")); |
9 | | - |
10 | | -switch ($this->getContext()->error) { |
11 | | - case "ALREADY_LOGGED_IN": |
12 | | - $message = "You are already logged in, you must log out first."; |
13 | | - break; |
14 | | - case "EMPTY_EMAIL": |
15 | | - $message = "The email address was left blank."; |
16 | | - break; |
17 | | - case "USER_NOT_FOUND": |
18 | | - case "PASSWORD_INCORRECT": |
19 | | - $message = "Incorrect email address or password."; |
20 | | - break; |
21 | | - case "USER_DISABLED": |
22 | | - $message = "The account has been administratively disabled."; |
23 | | - break; |
24 | | - case "USER_NOT_VERIFIED": |
25 | | - $message = "The account's identity has not been verified yet. " |
26 | | - . "No email yet? Use the Recover Password button."; |
27 | | - break; |
28 | | - case "LOGIN_DISABLED": |
29 | | - $message = "Logging in has been administratively disabled indefinitely."; |
30 | | - break; |
31 | | - default: |
32 | | - $message = $this->getContext()->error; |
| 5 | +$title = 'Account Login'; |
| 6 | +$description = 'This form enables a user to log in to their account.'; |
| 7 | +$this->opengraph->attach(new Pair('url', '/user/login')); |
| 8 | +$email = filter_var($this->getContext()->email, FILTER_SANITIZE_FULL_SPECIAL_CHARS); |
| 9 | +$error = $this->getContext()->error; |
| 10 | +switch ($error) |
| 11 | +{ |
| 12 | + case 'ALREADY_LOGGED_IN': $message = 'You are already logged in, you must log out first.'; break; |
| 13 | + case 'EMPTY_EMAIL': $message = 'The email address was left blank.'; break; |
| 14 | + case 'USER_NOT_FOUND': |
| 15 | + case 'PASSWORD_INCORRECT': $message = 'Incorrect email address or password.'; break; |
| 16 | + case 'USER_DISABLED': $message = 'The account has been administratively disabled.'; break; |
| 17 | + case 'USER_NOT_VERIFIED': $message = 'The account\'s identity has not been verified yet. No email yet? Use the Recover Password button.'; break; |
| 18 | + case 'LOGIN_DISABLED': $message = 'Logging in has been administratively disabled indefinitely.'; break; |
| 19 | + default: $message = $error; |
33 | 20 | } |
34 | | - |
35 | | -require("./header.inc.phtml"); |
36 | | -?> |
37 | | - <article> |
38 | | -<?php if ($this->getContext()->error !== false) { ?> |
39 | | - <header>Account Login</header> |
40 | | -<?php if (!empty($message)) { ?> |
41 | | - <section class="red"> |
42 | | - <p><?php echo $message; ?></p> |
43 | | - </section> |
44 | | -<?php } ?> |
45 | | - <form method="POST" action="?"> |
46 | | - <section> |
47 | | - <table> |
48 | | - <thead></thead> |
49 | | - <tbody> |
50 | | - <tr> |
51 | | - <td> |
52 | | - <label for="email">Email address:</label><br/> |
53 | | - <input |
54 | | - type="email" |
55 | | - name="email" |
56 | | - id="email" |
57 | | - value="<?=filter_var($this->getContext()->email, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>" |
58 | | - tabindex="1" |
59 | | - required |
60 | | - autocomplete="email" |
61 | | - autofocus="autofocus" |
62 | | - /> |
63 | | - </td><td> |
64 | | - <label for="password">Password:</label><br/> |
65 | | - <input |
66 | | - type="password" |
67 | | - name="password" |
68 | | - id="password" |
69 | | - value="" |
70 | | - tabindex="2" |
71 | | - /> |
72 | | - </td> |
73 | | - </tr> |
74 | | - </tbody> |
75 | | - </table> |
76 | | - <p style="color:rgba(128,128,128,0.8);">Session lifetime is 1 month.</p> |
77 | | - <hr/> |
78 | | - <input |
79 | | - type="submit" |
80 | | - value="Log In" |
81 | | - tabindex="3" |
82 | | - /> |
83 | | - <a class="button" style="margin-left:8px;" |
84 | | - href="<?php echo Common::relativeUrlToAbsolute("/user/resetpassword"); ?>" |
85 | | - tabindex="4" |
86 | | - >Recover Password</a> |
87 | | - </section> |
88 | | - </form> |
89 | | -<?php } else { ?> |
90 | | - <header class="green">Logged In</header> |
91 | | - <section class="green"> |
92 | | - <p>You have successfully logged in!</p> |
93 | | - <p>Use the navigation to the left to move to another page.</p> |
94 | | - </section> |
95 | | -<?php } ?> |
96 | | - </article> |
97 | | -<?php require("./footer.inc.phtml"); ?> |
| 21 | +require('./header.inc.phtml'); ?> |
| 22 | +<div class="container"> |
| 23 | +<? if ($error !== false) { ?> |
| 24 | + <h1><?=$title?></h1> |
| 25 | +<? if (!empty($message)) { ?> |
| 26 | + <div class="alert alert-danger"> |
| 27 | + <p class="mb-0"><?=$message?></p> |
| 28 | + </div> |
| 29 | +<? } ?> |
| 30 | + <form method="POST" action="?"> |
| 31 | + <div class="card"><div class="card-body"> |
| 32 | + <div class="form-group"> |
| 33 | + <label class="font-weight-bold" for="email">Email address:</label> |
| 34 | + <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" /> |
| 35 | + </div> |
| 36 | + <div class="form-group"> |
| 37 | + <label class="font-weight-bold" for="password">Password:</label> |
| 38 | + <input class="bg-dark border border-primary form-control text-light" type="password" name="password" id="password" placeholder="Enter the password here" value="" tabindex="2"/> |
| 39 | + </div> |
| 40 | + <p class="text-muted">Session lifetime is 1 month.</p> |
| 41 | + <input class="btn btn-success" type="submit" value="Log In" tabindex="3"/> |
| 42 | + <a class="btn btn-primary" href="<?=Common::relativeUrlToAbsolute('/user/resetpassword')?>" tabindex="4">Recover Password</a> |
| 43 | + </div></div> |
| 44 | + </form> |
| 45 | +<? } else { ?> |
| 46 | + <h1 class="text-success">Logged In</h1> |
| 47 | + <div class="alert alert-success"> |
| 48 | + <p class="mb-0">You have successfully logged in!</p> |
| 49 | + </div> |
| 50 | +<? } ?> |
| 51 | +</div> |
| 52 | +<? require('./footer.inc.phtml'); ?> |
0 commit comments