Files
AI_CPA/frontend/login.html
T
2026-07-15 12:30:28 +05:30

111 lines
4.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>BookKeepPro | Login</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet"/>
<link rel="stylesheet" href="/css/base.css"/>
<link rel="stylesheet" href="/css/components.css"/>
<link rel="stylesheet" href="/css/animations.css"/>
<style>html,body{height:100%;}body{margin:0;}</style> <script src="/js/theme.js?v=2"></script>
</head>
<body style="margin:0;padding:0;">
<div class="auth-shell page-enter">
<!-- Brand Panel -->
<div class="auth-brand">
<img class="brand-logo" src="/images/bookkeeppro-logo.webp" alt="BookKeepPro"/>
<div class="brand-divider"></div>
<h2>Welcome Back</h2>
<p>Secure access to your bookkeeping portal. Upload documents, track filings, and stay organised.</p>
</div>
<!-- Form Panel -->
<div class="auth-form-side">
<div class="auth-box">
<a href="/" class="fancy-link" style="display:inline-block; margin-bottom: 1.5rem; font-size: 0.95rem; font-weight: 500;">&larr; Back to Home</a>
<h1>Sign In</h1>
<p class="auth-subtitle">Enter your credentials to continue</p>
<div class="form-group">
<label class="form-label" for="email">Email Address</label>
<input id="email" type="email" class="input" placeholder="you@example.com" required/>
</div>
<div class="form-group">
<label class="form-label" for="password">Password</label>
<div class="password-wrap">
<input id="password" type="password" class="input" placeholder="Your password" required/>
<button type="button" class="password-toggle" id="toggleBtn" onclick="togglePassword()">Show</button>
</div>
</div>
<button class="btn btn-primary w-full" onclick="loginUser()" style="border-radius:var(--radius-sm);margin-top:4px;">
Sign In
</button>
<div class="auth-links">
<a href="/forgot-password" class="fancy-link">Forgot password?</a><br/>
Don't have an account? <a href="/signup" class="fancy-link">Sign Up</a>
</div>
</div>
</div>
</div>
<script src="/js/spinner.js"></script>
<script src="/js/toast.js"></script>
<script>
async function loginUser() {
const email = document.getElementById("email").value.trim();
const password = document.getElementById("password").value;
const btn = document.querySelector(".btn-primary");
if (!email || !password) return showToast("Enter email and password", "warning");
setButtonLoading(btn, true, "Signing in...");
const res = await fetch("/api/auth/login", {
method: "POST", headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password })
});
const data = await res.json();
setButtonLoading(btn, false, "Sign In");
if (!res.ok) {
if (data.detail === "EMAIL_NOT_VERIFIED") {
document.querySelector(".auth-box").innerHTML = `
<div style="text-align:center;padding:16px 0;">
<div style="font-size:52px;margin-bottom:16px;">📧</div>
<h2 style="margin-bottom:12px;">Email Not Verified</h2>
<p style="margin-bottom:20px;">Please verify your email address before logging in.<br>Check your inbox for the verification link.</p>
<a href="/resend-verification" class="btn btn-primary" style="border-radius:var(--radius-sm);">Resend Verification Email</a>
<div style="margin-top:16px;"><a href="/login" class="fancy-link">Try a different account</a></div>
</div>`;
return;
}
return showToast(data.detail || "Login failed", "error");
}
localStorage.setItem("token", data.access_token);
localStorage.setItem("role", data.role);
localStorage.setItem("user_id", data.user_id);
window.location.href = (data.role === "admin" || data.role === "super_admin")
? "/admin-dashboard" : "/dashboard";
}
function togglePassword() {
const pwd = document.getElementById("password");
const btn = document.getElementById("toggleBtn");
pwd.type = pwd.type === "password" ? "text" : "password";
btn.textContent = pwd.type === "password" ? "Show" : "Hide";
}
</script>
</body>
</html>