(feat): added captcha for invalid login
This commit is contained in:
@@ -88,9 +88,6 @@
|
||||
<div class="col-sm" id="loginStatus">
|
||||
<?php
|
||||
|
||||
if ($view->loginError) {
|
||||
require_once('Views/template/loginError.phtml');
|
||||
}
|
||||
if(!$view->user->isLoggedIn()) {
|
||||
require_once('Views/template/loginModal.phtml');
|
||||
}
|
||||
|
@@ -0,0 +1,18 @@
|
||||
<span class="ms-5 me-5 row alert alert-danger" role="alert"><?= $view->loginError ?></span>
|
||||
<div class="row captcha-container">
|
||||
<!-- CAPTCHA Display -->
|
||||
<div class="form-floating mb-3 col">
|
||||
<input type="text" class="form-control" id="captchaCode" value="<?php
|
||||
// Generate a simple 5-character CAPTCHA
|
||||
$captcha = substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"), 0, 5);
|
||||
echo $captcha;
|
||||
?>" readonly>
|
||||
<label for="captchaCode">CAPTCHA Code</label>
|
||||
</div>
|
||||
|
||||
<!-- CAPTCHA Input -->
|
||||
<div class="form-floating mb-3 col">
|
||||
<input type="text" class="form-control" id="captchaInput" name="captchaInput" placeholder="Enter CAPTCHA" required>
|
||||
<label for="captchaInput">Enter CAPTCHA</label>
|
||||
</div>
|
||||
</div>
|
@@ -1,7 +1,11 @@
|
||||
<button type="button" class="btn bg-primary btn-outline-primary text-light m-auto" data-bs-toggle="modal" data-bs-target="#loginModal">
|
||||
<button type="button" class="btn bg-primary btn-outline-primary text-light m-auto" data-bs-toggle="modal"
|
||||
data-bs-target="#loginModal">
|
||||
Login
|
||||
</button>
|
||||
<div class="modal fade" id="loginModal" tabindex="-1" aria-labelledby="loginModalLabel" aria-hidden="true">
|
||||
<?= isset($view->loginError) ? '<div class="modal-backdrop fade show"></div>' : '' ?>
|
||||
<div class="modal fade <?= isset($view->loginError) ? 'show' : '' ?>" id="loginModal" tabindex="-1"
|
||||
aria-labelledby="loginModalLabel" aria-hidden="<?= isset($view->loginError) ? 'false' : 'true' ?>"
|
||||
style="<?= isset($view->loginError) ? 'display: block;' : '' ?>">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@@ -12,17 +16,23 @@
|
||||
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">Username</label>
|
||||
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required>
|
||||
<input type="text" class="form-control" id="username" name="username" placeholder="Username"
|
||||
required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="Password"
|
||||
required>
|
||||
</div>
|
||||
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="loginButton">Login</button>
|
||||
<?php if (isset($view->loginError)) { include('Views/template/loginError.phtml');} ?>
|
||||
<button type="submit" class="btn bg-primary btn-outline-primary text-light" name="loginButton">Login
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-warning btn-outline-warning text-light" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-warning btn-outline-warning text-light" data-bs-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user