71 lines
3.5 KiB
HTML
71 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" class="light">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Confirm Email - AccManager</title>
|
|
<link rel="stylesheet" href="../css/main.css" />
|
|
<style>
|
|
body { font-family: 'Inter', sans-serif; min-height: 100vh; }
|
|
</style>
|
|
</head>
|
|
<body class="bg-gradient-to-br from-slate-100 via-white to-blue-100 text-slate-900 antialiased">
|
|
<main class="min-h-screen flex items-center justify-center px-4">
|
|
<section class="w-full max-w-md bg-white rounded-2xl border border-slate-200 shadow-lg p-8">
|
|
<h1 class="text-2xl font-black tracking-tight mb-2">Email Confirmation</h1>
|
|
<p class="text-sm text-slate-600 mb-6">We are confirming your account.</p>
|
|
|
|
<div id="statusBox" class="rounded-lg border px-4 py-3 text-sm bg-slate-50 border-slate-200 text-slate-700">
|
|
Confirming your email, please wait...
|
|
</div>
|
|
|
|
<div class="mt-6 flex gap-3">
|
|
<a href="./login.html" class="flex-1 text-center px-4 py-2 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-700 font-semibold transition-colors">Back to Login</a>
|
|
<a id="signInBtn" href="./login.html" class="hidden flex-1 text-center px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors">Sign In</a>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
|
|
<script>
|
|
(async () => {
|
|
const statusBox = document.getElementById('statusBox');
|
|
const signInBtn = document.getElementById('signInBtn');
|
|
const params = new URLSearchParams(window.location.search);
|
|
const token = params.get('token');
|
|
|
|
if (!token) {
|
|
statusBox.className = 'rounded-lg border px-4 py-3 text-sm bg-red-50 border-red-200 text-red-700';
|
|
statusBox.textContent = 'Missing verification token.';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(`/api/auth/verify-email?token=${encodeURIComponent(token)}`);
|
|
const data = await response.json();
|
|
|
|
if (response.ok && data.success) {
|
|
statusBox.className = 'rounded-lg border px-4 py-3 text-sm bg-green-50 border-green-200 text-green-700';
|
|
if (data.autoLogin && data.user) {
|
|
localStorage.setItem('currentUser', JSON.stringify(data.user));
|
|
statusBox.textContent = data.message || 'Email confirmed. Redirecting to dashboard...';
|
|
setTimeout(() => {
|
|
window.location.href = './index.html';
|
|
}, 1000);
|
|
} else {
|
|
statusBox.textContent = data.message || 'Email confirmed successfully.';
|
|
signInBtn.classList.remove('hidden');
|
|
}
|
|
} else {
|
|
statusBox.className = 'rounded-lg border px-4 py-3 text-sm bg-red-50 border-red-200 text-red-700';
|
|
statusBox.textContent = data.message || 'Email confirmation failed.';
|
|
}
|
|
} catch (error) {
|
|
statusBox.className = 'rounded-lg border px-4 py-3 text-sm bg-red-50 border-red-200 text-red-700';
|
|
statusBox.textContent = 'Cannot verify email right now. Please try again later.';
|
|
console.error('Verify email page error:', error);
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|