46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
<title>Login panel for admins</title>
|
|
<body>
|
|
<div class="min-h-screen flex items-center justify-center bg-gray-100">
|
|
<form id="login-form" class="bg-white p-8 rounded-2xl shadow-xl w-full max-w-sm space-y-6">
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium text-gray-700 mb-1">Discrete password</label>
|
|
<input
|
|
id="password"
|
|
name="password"
|
|
type="password"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition"
|
|
/>
|
|
</div>
|
|
<button
|
|
type="submit"
|
|
class="w-full bg-black text-white font-semibold py-2 rounded-md hover:bg-gray-800 transition-colors"
|
|
>
|
|
Login
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
document.querySelector('#login-form').addEventListener('submit', function(event) {
|
|
event.preventDefault();
|
|
const password = document.querySelector('input[name="password"]').value;
|
|
|
|
fetch('/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ password })
|
|
})
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
window.location.href = '/blogs';
|
|
})
|
|
.catch(err => {
|
|
console.error('Login error:', err);
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|