feat: Create login.html with username, password, and reCAPTCHA
This commit is contained in:
1 parent
d5edb4d1c2
commit
c12859f146
1 file changed
+197
+197
@@ -0,0 +1,197 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="node_modules/bulma/css/bulma.min.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<!-- Include Google reCAPTCHA API script -->
|
||||
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
||||
<title>Login - Behind the Desk</title>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar is-fixed-top" role="navigation" aria-label="main navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item has-text-weight-bold" href="index.html"> <!-- Link back to index -->
|
||||
Behind the Desk
|
||||
</a>
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="navbarBasicExample" class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<a class="navbar-item" href="index.html"> <!-- Link back to index -->
|
||||
top 🔥
|
||||
</a>
|
||||
<a class="navbar-item" href="#">
|
||||
new
|
||||
</a>
|
||||
<a class="navbar-item" href="#">
|
||||
nearby
|
||||
</a>
|
||||
<a class="navbar-item" href="#">
|
||||
past
|
||||
</a>
|
||||
<a class="navbar-item" href="#">
|
||||
ask
|
||||
</a>
|
||||
<a class="navbar-item" href="#">
|
||||
show
|
||||
</a>
|
||||
<a class="navbar-item" href="#">
|
||||
submit
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<a href="#">Login</a> <!-- Changed handle to Login link -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="section main-content">
|
||||
<div class="container">
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-half">
|
||||
<h1 class="title has-text-centered">Login</h1>
|
||||
<div class="box">
|
||||
<form id="login-form">
|
||||
<div class="field">
|
||||
<label class="label" for="username">Username</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" id="username" name="username" placeholder="Enter your username" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="password">Password</label>
|
||||
<div class="control">
|
||||
<input class="input" type="password" id="password" name="password" placeholder="Enter your password" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="confirm-password">Confirm Password</label>
|
||||
<div class="control">
|
||||
<input class="input" type="password" id="confirm-password" name="confirm-password" placeholder="Confirm your password" required>
|
||||
</div>
|
||||
<p class="help is-danger is-hidden" id="password-mismatch">Passwords do not match.</p>
|
||||
</div>
|
||||
|
||||
<!-- reCAPTCHA Widget -->
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<div class="g-recaptcha" data-sitekey="YOUR_RECAPTCHA_SITE_KEY"></div>
|
||||
<!-- IMPORTANT: Replace YOUR_RECAPTCHA_SITE_KEY with your actual site key -->
|
||||
</div>
|
||||
<p class="help is-danger is-hidden" id="recaptcha-error">Please complete the reCAPTCHA.</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button type="submit" class="button is-primary is-fullwidth">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<p class="has-text-centered">
|
||||
Don't have an account? <a href="signup.html">Sign up</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- End container -->
|
||||
</main>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
Seen something today? Don’t let it go to waste. <a href="#">Submit it</a>.
|
||||
</p>
|
||||
<div class="footer-menu">
|
||||
<a href="#">Guidelines</a> |
|
||||
<a href="#">Tips</a> |
|
||||
<a href="#">Privacy</a> |
|
||||
<a href="#">DMCA</a>
|
||||
</div>
|
||||
<div class="search-box">
|
||||
<input type="text" placeholder="Search...">
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Simple script to toggle mobile menu -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Navbar burger toggle
|
||||
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
||||
if ($navbarBurgers.length > 0) {
|
||||
$navbarBurgers.forEach( el => {
|
||||
el.addEventListener('click', () => {
|
||||
const target = el.dataset.target;
|
||||
const $target = document.getElementById(target);
|
||||
el.classList.toggle('is-active');
|
||||
$target.classList.toggle('is-active');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Basic form validation example (password match)
|
||||
const loginForm = document.getElementById('login-form');
|
||||
const passwordInput = document.getElementById('password');
|
||||
const confirmPasswordInput = document.getElementById('confirm-password');
|
||||
const passwordMismatchHelp = document.getElementById('password-mismatch');
|
||||
const recaptchaErrorHelp = document.getElementById('recaptcha-error');
|
||||
|
||||
if (loginForm) {
|
||||
loginForm.addEventListener('submit', function(event) {
|
||||
let isValid = true;
|
||||
|
||||
// Check password match
|
||||
if (passwordInput.value !== confirmPasswordInput.value) {
|
||||
confirmPasswordInput.classList.add('is-danger');
|
||||
passwordMismatchHelp.classList.remove('is-hidden');
|
||||
isValid = false;
|
||||
event.preventDefault(); // Prevent submission
|
||||
} else {
|
||||
confirmPasswordInput.classList.remove('is-danger');
|
||||
passwordMismatchHelp.classList.add('is-hidden');
|
||||
}
|
||||
|
||||
// Check reCAPTCHA response (basic check, server-side validation is crucial)
|
||||
const recaptchaResponse = grecaptcha.getResponse();
|
||||
if (recaptchaResponse.length === 0) {
|
||||
recaptchaErrorHelp.classList.remove('is-hidden');
|
||||
isValid = false;
|
||||
event.preventDefault(); // Prevent submission
|
||||
} else {
|
||||
recaptchaErrorHelp.classList.add('is-hidden');
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
// Optionally scroll to the first error or provide more feedback
|
||||
}
|
||||
// IMPORTANT: Remember to perform server-side validation for passwords and reCAPTCHA!
|
||||
});
|
||||
|
||||
// Real-time password match check (optional)
|
||||
confirmPasswordInput.addEventListener('input', () => {
|
||||
if (passwordInput.value !== confirmPasswordInput.value) {
|
||||
confirmPasswordInput.classList.add('is-danger');
|
||||
passwordMismatchHelp.classList.remove('is-hidden');
|
||||
} else {
|
||||
confirmPasswordInput.classList.remove('is-danger');
|
||||
passwordMismatchHelp.classList.add('is-hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user