Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F15177736
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/include/class-PageLogin.php b/include/class-PageLogin.php
index 7aa1fee..14a0ffa 100644
--- a/include/class-PageLogin.php
+++ b/include/class-PageLogin.php
@@ -1,31 +1,48 @@
<?php
/**
* Login page of my website
*/
class PageLogin extends Page {
/**
* Do something at startup
*
* @override
*/
protected function prepare() {
- // eventually go to the homepage
- if( is_logged() ) {
- http_redirect( '' );
- }
-
// set the page title
$this->setTitle( __( "Login" ) );
// check if we should do the login
- if( is_action( 'do-login' ) ) {
+ if( $this->isLoginFormSubmitted() ) {
- // process the login form
+ // process the user_uid and the user_password sent via POST
login();
}
+ // eventually go to the homepage if logged-in
+ if( is_logged() ) {
+ http_redirect( '', 303 );
+ }
+ }
+
+ /**
+ * Check if the login form was submitted
+ *
+ * @return boolean
+ */
+ public function isLoginFormSubmitted() {
+ return is_action( 'do-login' );
+ }
+
+ /**
+ * Check if the login failed
+ *
+ * @return boolean
+ */
+ public function isLoginFormFailed() {
+ return $this->isLoginFormSubmitted() && !is_logged();
}
}
diff --git a/www/login.php b/www/login.php
index bafab2d..6e5bb2a 100644
--- a/www/login.php
+++ b/www/login.php
@@ -1,36 +1,44 @@
<?php
// load everything
require '../load.php';
// this is the homepage (the business logic of this page it's in this class)
$page = new PageLogin();
// print site header
$page->printHeader();
?>
+ <!-- login failed warning -->
+ <?php if( $page->isLoginFormSubmitted() ): ?>
+ <div class="card-panel">
+ <p><?= __( "Login failed!" ) ?></p>
+ </div>
+ <?php endif ?>
+
+ <!-- login form -->
<form method="post">
<?php form_action( 'do-login' ) ?>
<!-- username -->
<p>
<label for="user-uid"><?= esc_html( __( "Username" ) ) ?></label>
<br />
- <input id="user-uid" name="user_uid" />
+ <input type="text" id="user-uid" name="user_uid" />
</p>
<!-- password -->
<p>
<label for="user-pwd"><?= esc_html( __( "Password" ) ) ?></label>
<br />
- <input id="user-pwd" name="user_password" />
+ <input type="password" id="user-pwd" name="user_password" />
</p>
<!-- submit button -->
<p><button><?= esc_html( __( "Login" ) ) ?></button></p>
</form>
<?php
$page->printFooter();
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Nov 19, 04:04 (5 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264688
Default Alt Text
(2 KB)
Attached To
Mode
R22 WikiCAPTCHA Control Room
Attached
Detach File
Event Timeline