deedrop1140's picture
Upload 182 files
d0a6b4f verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="min-h-screen bg-gradient-to-br from-indigo-600 to-purple-700 flex items-center justify-center">
<div class="bg-white w-full max-w-md rounded-2xl shadow-xl p-8">
<h2 class="text-3xl font-bold text-center text-gray-800">Welcome Back</h2>
<p class="text-center text-gray-500 mt-2">Login to continue</p>
<form method="POST" class="mt-6 space-y-4">
<input type="email" name="email" placeholder="Email"
required
class="w-full px-4 py-3 rounded-lg border focus:ring-2 focus:ring-indigo-500 outline-none">
<input type="password" name="password" placeholder="Password"
required
class="w-full px-4 py-3 rounded-lg border focus:ring-2 focus:ring-indigo-500 outline-none">
<button
class="w-full bg-indigo-600 hover:bg-indigo-700 text-white py-3 rounded-lg font-semibold transition">
Login
</button>
</form>
<div class="flex justify-between text-sm mt-4 text-gray-600">
<a href="/auth/register" class="hover:underline">Create account</a>
<a href="/auth/forgot" class="hover:underline">Forgot password?</a>
</div>
</div>
<script>
const form = document.querySelector("form");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(form);
const res = await fetch("/auth/login", {
method: "POST",
body: formData
});
const data = await res.json();
if (data.access_token) {
// ✅ SAVE JWT
localStorage.setItem("jwt_token", data.access_token);
// ✅ GO TO HOME
window.location.href = "/";
} else {
alert("Login failed");
}
});
</script>
<div id="alertBox"
class="hidden fixed top-5 right-5 max-w-sm px-5 py-4 rounded-lg shadow-lg text-white">
</div>
{% if success %}
<script>
showAlert("{{ success }}", "success");
</script>
{% endif %}
</body>
</html>