Update login.html
Browse files- login.html +76 -76
login.html
CHANGED
|
@@ -1,76 +1,76 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<title>Login – TrueWrite Scan</title>
|
| 6 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 7 |
-
</head>
|
| 8 |
-
<body class="bg-slate-950 text-white min-h-screen flex items-center justify-center">
|
| 9 |
-
<div class="max-w-md w-full mx-4 bg-slate-900/70 border border-slate-800 rounded-2xl p-6 shadow-xl">
|
| 10 |
-
<h1 class="text-2xl font-bold mb-1">Welcome back</h1>
|
| 11 |
-
<p class="text-xs text-slate-400 mb-4">Login to continue using TrueWrite Scan.</p>
|
| 12 |
-
|
| 13 |
-
<form id="loginForm" class="space-y-4">
|
| 14 |
-
<div>
|
| 15 |
-
<label class="block text-xs mb-1">Email</label>
|
| 16 |
-
<input id="email" type="email" required
|
| 17 |
-
class="w-full px-3 py-2 rounded-lg bg-slate-950 border border-slate-700 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500" />
|
| 18 |
-
</div>
|
| 19 |
-
<div>
|
| 20 |
-
<label class="block text-xs mb-1">Password</label>
|
| 21 |
-
<input id="password" type="password" required
|
| 22 |
-
class="w-full px-3 py-2 rounded-lg bg-slate-950 border border-slate-700 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500" />
|
| 23 |
-
</div>
|
| 24 |
-
<p id="loginError" class="text-xs text-red-400 h-4"></p>
|
| 25 |
-
<button type="submit"
|
| 26 |
-
class="w-full py-2 rounded-lg bg-indigo-500 hover:bg-indigo-600 text-sm font-semibold">
|
| 27 |
-
Login
|
| 28 |
-
</button>
|
| 29 |
-
</form>
|
| 30 |
-
|
| 31 |
-
<p class="mt-4 text-xs text-slate-400 text-center">
|
| 32 |
-
New to TrueWrite Scan?
|
| 33 |
-
<a href="signup.html" class="text-indigo-300 underline underline-offset-2">Create account</a>
|
| 34 |
-
</p>
|
| 35 |
-
</div>
|
| 36 |
-
|
| 37 |
-
<script>
|
| 38 |
-
const BACKEND_URL = "
|
| 39 |
-
|
| 40 |
-
const form = document.getElementById("loginForm");
|
| 41 |
-
const err = document.getElementById("loginError");
|
| 42 |
-
|
| 43 |
-
form.addEventListener("submit", async (e) => {
|
| 44 |
-
e.preventDefault();
|
| 45 |
-
err.textContent = "";
|
| 46 |
-
|
| 47 |
-
const email = document.getElementById("email").value.trim();
|
| 48 |
-
const password = document.getElementById("password").value;
|
| 49 |
-
|
| 50 |
-
try {
|
| 51 |
-
const res = await fetch(`${BACKEND_URL}/api/login`, {
|
| 52 |
-
method: "POST",
|
| 53 |
-
headers: { "Content-Type": "application/json" },
|
| 54 |
-
body: JSON.stringify({ email, password })
|
| 55 |
-
});
|
| 56 |
-
|
| 57 |
-
const data = await res.json();
|
| 58 |
-
if (!res.ok) {
|
| 59 |
-
err.textContent = data.detail || "Login failed";
|
| 60 |
-
return;
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
localStorage.setItem("truewriteToken", data.token);
|
| 64 |
-
localStorage.setItem("truewriteUser", JSON.stringify({
|
| 65 |
-
name: data.name,
|
| 66 |
-
email: data.email
|
| 67 |
-
}));
|
| 68 |
-
|
| 69 |
-
window.location.href = "dashboard.html";
|
| 70 |
-
} catch (e2) {
|
| 71 |
-
err.textContent = "Server error. Is backend running?";
|
| 72 |
-
}
|
| 73 |
-
});
|
| 74 |
-
</script>
|
| 75 |
-
</body>
|
| 76 |
-
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<title>Login – TrueWrite Scan</title>
|
| 6 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 7 |
+
</head>
|
| 8 |
+
<body class="bg-slate-950 text-white min-h-screen flex items-center justify-center">
|
| 9 |
+
<div class="max-w-md w-full mx-4 bg-slate-900/70 border border-slate-800 rounded-2xl p-6 shadow-xl">
|
| 10 |
+
<h1 class="text-2xl font-bold mb-1">Welcome back</h1>
|
| 11 |
+
<p class="text-xs text-slate-400 mb-4">Login to continue using TrueWrite Scan.</p>
|
| 12 |
+
|
| 13 |
+
<form id="loginForm" class="space-y-4">
|
| 14 |
+
<div>
|
| 15 |
+
<label class="block text-xs mb-1">Email</label>
|
| 16 |
+
<input id="email" type="email" required
|
| 17 |
+
class="w-full px-3 py-2 rounded-lg bg-slate-950 border border-slate-700 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500" />
|
| 18 |
+
</div>
|
| 19 |
+
<div>
|
| 20 |
+
<label class="block text-xs mb-1">Password</label>
|
| 21 |
+
<input id="password" type="password" required
|
| 22 |
+
class="w-full px-3 py-2 rounded-lg bg-slate-950 border border-slate-700 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500" />
|
| 23 |
+
</div>
|
| 24 |
+
<p id="loginError" class="text-xs text-red-400 h-4"></p>
|
| 25 |
+
<button type="submit"
|
| 26 |
+
class="w-full py-2 rounded-lg bg-indigo-500 hover:bg-indigo-600 text-sm font-semibold">
|
| 27 |
+
Login
|
| 28 |
+
</button>
|
| 29 |
+
</form>
|
| 30 |
+
|
| 31 |
+
<p class="mt-4 text-xs text-slate-400 text-center">
|
| 32 |
+
New to TrueWrite Scan?
|
| 33 |
+
<a href="signup.html" class="text-indigo-300 underline underline-offset-2">Create account</a>
|
| 34 |
+
</p>
|
| 35 |
+
</div>
|
| 36 |
+
|
| 37 |
+
<script>
|
| 38 |
+
const BACKEND_URL = "https://gopalkrushnamahapatra-truewrite-scan.hf.space";
|
| 39 |
+
|
| 40 |
+
const form = document.getElementById("loginForm");
|
| 41 |
+
const err = document.getElementById("loginError");
|
| 42 |
+
|
| 43 |
+
form.addEventListener("submit", async (e) => {
|
| 44 |
+
e.preventDefault();
|
| 45 |
+
err.textContent = "";
|
| 46 |
+
|
| 47 |
+
const email = document.getElementById("email").value.trim();
|
| 48 |
+
const password = document.getElementById("password").value;
|
| 49 |
+
|
| 50 |
+
try {
|
| 51 |
+
const res = await fetch(`${BACKEND_URL}/api/login`, {
|
| 52 |
+
method: "POST",
|
| 53 |
+
headers: { "Content-Type": "application/json" },
|
| 54 |
+
body: JSON.stringify({ email, password })
|
| 55 |
+
});
|
| 56 |
+
|
| 57 |
+
const data = await res.json();
|
| 58 |
+
if (!res.ok) {
|
| 59 |
+
err.textContent = data.detail || "Login failed";
|
| 60 |
+
return;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
localStorage.setItem("truewriteToken", data.token);
|
| 64 |
+
localStorage.setItem("truewriteUser", JSON.stringify({
|
| 65 |
+
name: data.name,
|
| 66 |
+
email: data.email
|
| 67 |
+
}));
|
| 68 |
+
|
| 69 |
+
window.location.href = "dashboard.html";
|
| 70 |
+
} catch (e2) {
|
| 71 |
+
err.textContent = "Server error. Is backend running?";
|
| 72 |
+
}
|
| 73 |
+
});
|
| 74 |
+
</script>
|
| 75 |
+
</body>
|
| 76 |
+
</html>
|