|
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<title>Login</title> |
|
|
|
<link rel="stylesheet" type="text/css" href="/static/style2.css"> |
|
<script src="https://apis.google.com/js/platform.js" async defer></script> |
|
<meta name="google-signin-client_id" content="526344692420-4sc5t4ie33n4p365cm25urna72u7stpb.apps.googleusercontent.com"> |
|
</head> |
|
<body> |
|
<footer> |
|
|
|
<p>Copyright © Your Website</p> |
|
</footer> |
|
<div class="background-container"> |
|
<div class="color-overlay"></div> |
|
<h1>Login</h1> |
|
{% if error_message %} |
|
<p style="color: red;">{{ error_message }}</p> |
|
{% endif %} |
|
<form method="post" action="/login" id="login-form"> |
|
<label for="email">Email:</label> |
|
<input type="text" id="email" name="email" required><br><br> |
|
|
|
<label for="password">Password:</label> |
|
<input type="password" id="password" name="password" required><br><br> |
|
|
|
|
|
|
|
<input type="hidden" id="recaptcha_token" name="recaptcha_token" value=""> |
|
<div class="recaptcha-container"> |
|
<div class="g-recaptcha" |
|
data-sitekey="6LeSJgwpAAAAAD9UlPdC911k8UgD6Uh3068xXgGj" |
|
data-callback="setRecaptchaToken"></div></div> |
|
<br> |
|
<button type="submit">Login</button> |
|
</form> |
|
|
|
<div class="g-signin2" data-onsuccess="onSignIn"></div> |
|
|
|
<script> |
|
function onSignIn(googleUser) { |
|
var id_token = googleUser.getAuthResponse().id_token; |
|
|
|
fetch('/verify-google-token', { |
|
method: 'POST', |
|
headers: { |
|
'Content-Type': 'application/json' |
|
}, |
|
body: JSON.stringify({ token: id_token }) |
|
}) |
|
.then(response => { |
|
if (response.redirected) { |
|
|
|
window.location.href = response.url; |
|
} else { |
|
return response.json(); |
|
} |
|
}) |
|
.then(data => { |
|
|
|
console.log(data); |
|
}) |
|
.catch(error => console.error('Error:', error)); |
|
} |
|
</script> |
|
|
|
<script src="https://www.google.com/recaptcha/api.js" async defer></script> |
|
<script> |
|
function setRecaptchaToken(token) { |
|
document.getElementById('recaptcha_token').value = token; |
|
} |
|
document.getElementById('login-form').addEventListener('submit', function(event) { |
|
|
|
var token = document.getElementById('recaptcha_token').value; |
|
var email = document.getElementById('email').value; |
|
var password = document.getElementById('password').value; |
|
if (!(token && email && password)) { |
|
event.preventDefault(); |
|
alert("Please fill in all required fields."); |
|
} |
|
|
|
|
|
}); |
|
</script> |
|
</div> |
|
</body> |
|
</html> |
|
|