203 lines
8.6 KiB
HTML
203 lines
8.6 KiB
HTML
<!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 / Signup - Behind the Desk</title>
|
|
</head>
|
|
<body style="padding-top: 0;"> <!-- Remove navbar padding override -->
|
|
<!-- Navbar Removed -->
|
|
|
|
<main class="section main-content">
|
|
<div class="container">
|
|
<div class="columns"> <!-- Use standard columns for side-by-side -->
|
|
<!-- Login Column -->
|
|
<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="login-username">Username</label>
|
|
<div class="control">
|
|
<input class="input" type="text" id="login-username" name="username" placeholder="Enter your username" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label class="label" for="login-password">Password</label>
|
|
<div class="control">
|
|
<input class="input" type="password" id="login-password" name="password" placeholder="Enter your password" required>
|
|
</div>
|
|
</div>
|
|
<!-- Confirm Password removed from Login -->
|
|
|
|
<div class="field">
|
|
<div class="control">
|
|
<button type="submit" class="button is-primary is-fullwidth">Login</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div> <!-- End Login Column -->
|
|
|
|
<!-- Signup Column -->
|
|
<div class="column is-half">
|
|
<h1 class="title has-text-centered">Sign Up</h1>
|
|
<div class="box">
|
|
<form id="signup-form">
|
|
<div class="field">
|
|
<label class="label" for="signup-username">Username</label>
|
|
<div class="control">
|
|
<input class="input" type="text" id="signup-username" name="username" placeholder="Choose a username" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label class="label" for="signup-email">Email</label>
|
|
<div class="control">
|
|
<input class="input" type="email" id="signup-email" name="email" placeholder="Enter your email" required>
|
|
</div>
|
|
<!-- Optional: Add help text for email format -->
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label class="label" for="signup-password">Password</label>
|
|
<div class="control">
|
|
<input class="input" type="password" id="signup-password" name="password" placeholder="Create a password" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label class="label" for="signup-confirm-password">Confirm Password</label>
|
|
<div class="control">
|
|
<input class="input" type="password" id="signup-confirm-password" name="confirm-password" placeholder="Confirm your password" required>
|
|
</div>
|
|
<p class="help is-danger is-hidden" id="signup-password-mismatch">Passwords do not match.</p>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<div class="control">
|
|
<button type="submit" class="button is-link is-fullwidth">Sign Up</button> <!-- Use is-link or another color for distinction -->
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div> <!-- End Signup Column -->
|
|
|
|
</div> <!-- End columns -->
|
|
|
|
<!-- Shared reCAPTCHA -->
|
|
<div class="columns is-centered">
|
|
<div class="column is-half">
|
|
<div class="field mt-4">
|
|
<div class="control has-text-centered"> <!-- Center the reCAPTCHA -->
|
|
<div class="g-recaptcha" data-sitekey="YOUR_RECAPTCHA_SITE_KEY" style="display: inline-block;"></div>
|
|
<!-- IMPORTANT: Replace YOUR_RECAPTCHA_SITE_KEY with your actual site key -->
|
|
</div>
|
|
<p class="help is-danger is-hidden has-text-centered" id="recaptcha-error">Please complete the reCAPTCHA.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div> <!-- End container -->
|
|
</main>
|
|
|
|
<!-- Footer Removed -->
|
|
|
|
<!-- Updated script for both forms -->
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
// Navbar burger toggle removed
|
|
|
|
const loginForm = document.getElementById('login-form');
|
|
const signupForm = document.getElementById('signup-form');
|
|
const recaptchaErrorHelp = document.getElementById('recaptcha-error');
|
|
|
|
// --- Login Form Validation ---
|
|
if (loginForm) {
|
|
loginForm.addEventListener('submit', function(event) {
|
|
let isValid = true;
|
|
// Basic validation (e.g., required fields handled by HTML5 'required')
|
|
|
|
// Check reCAPTCHA
|
|
const recaptchaResponse = grecaptcha.getResponse();
|
|
if (recaptchaResponse.length === 0) {
|
|
recaptchaErrorHelp.classList.remove('is-hidden');
|
|
isValid = false;
|
|
} else {
|
|
recaptchaErrorHelp.classList.add('is-hidden');
|
|
}
|
|
|
|
if (!isValid) {
|
|
event.preventDefault(); // Prevent submission if invalid
|
|
}
|
|
// Add further login validation if needed
|
|
// IMPORTANT: Remember server-side validation!
|
|
});
|
|
}
|
|
|
|
// --- Signup Form Validation ---
|
|
if (signupForm) {
|
|
const signupPasswordInput = document.getElementById('signup-password');
|
|
const signupConfirmPasswordInput = document.getElementById('signup-confirm-password');
|
|
const signupPasswordMismatchHelp = document.getElementById('signup-password-mismatch');
|
|
|
|
signupForm.addEventListener('submit', function(event) {
|
|
let isValid = true;
|
|
|
|
// Check password match
|
|
if (signupPasswordInput.value !== signupConfirmPasswordInput.value) {
|
|
signupConfirmPasswordInput.classList.add('is-danger');
|
|
signupPasswordMismatchHelp.classList.remove('is-hidden');
|
|
isValid = false;
|
|
} else {
|
|
signupConfirmPasswordInput.classList.remove('is-danger');
|
|
signupPasswordMismatchHelp.classList.add('is-hidden');
|
|
}
|
|
|
|
// Check reCAPTCHA
|
|
const recaptchaResponse = grecaptcha.getResponse();
|
|
if (recaptchaResponse.length === 0) {
|
|
recaptchaErrorHelp.classList.remove('is-hidden');
|
|
isValid = false;
|
|
} else {
|
|
recaptchaErrorHelp.classList.add('is-hidden');
|
|
}
|
|
|
|
if (!isValid) {
|
|
event.preventDefault(); // Prevent submission if invalid
|
|
}
|
|
// Add further signup validation if needed (email format, username availability via AJAX etc.)
|
|
// IMPORTANT: Remember server-side validation!
|
|
});
|
|
|
|
// Real-time password match check for signup (optional)
|
|
signupConfirmPasswordInput.addEventListener('input', () => {
|
|
if (signupPasswordInput.value !== signupConfirmPasswordInput.value) {
|
|
signupConfirmPasswordInput.classList.add('is-danger');
|
|
signupPasswordMismatchHelp.classList.remove('is-hidden');
|
|
} else {
|
|
signupConfirmPasswordInput.classList.remove('is-danger');
|
|
signupPasswordMismatchHelp.classList.add('is-hidden');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Reset reCAPTCHA error on interaction (optional, improves UX)
|
|
// This requires a more complex setup if using the invisible reCAPTCHA or explicit rendering.
|
|
// For the simple checkbox version, clicking it usually suffices.
|
|
// We can hide the error when either form attempts submission again.
|
|
if(recaptchaErrorHelp){
|
|
if(loginForm) loginForm.addEventListener('submit', () => recaptchaErrorHelp.classList.add('is-hidden'));
|
|
if(signupForm) signupForm.addEventListener('submit', () => recaptchaErrorHelp.classList.add('is-hidden'));
|
|
}
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|