File size: 2,121 Bytes
d0a6b4f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | <!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>
</script>
{% endif %}
</body>
</html>
|