83 lines
2.6 KiB
HTML
83 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Login - Demo</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.container {
|
|
background: white;
|
|
padding: 40px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
|
max-width: 400px;
|
|
width: 100%;
|
|
}
|
|
h1 { margin-bottom: 20px; color: #333; }
|
|
input {
|
|
width: 100%;
|
|
padding: 12px;
|
|
margin-bottom: 15px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 5px;
|
|
}
|
|
.btn {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background: #667eea;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
}
|
|
.btn:hover { background: #5568d3; }
|
|
a { color: #667eea; text-decoration: none; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🔐 Iniciar Sesión</h1>
|
|
<form id="loginForm">
|
|
<input type="email" id="email" placeholder="Email" required>
|
|
<input type="password" id="password" placeholder="Contraseña" required>
|
|
<button type="submit" class="btn">Iniciar Sesión</button>
|
|
</form>
|
|
<p style="text-align: center; margin-top: 15px;">
|
|
<a href="/register">¿No tienes cuenta? Regístrate</a>
|
|
</p>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const data = {
|
|
email: document.getElementById('email').value,
|
|
password: document.getElementById('password').value
|
|
};
|
|
|
|
const res = await fetch('/login', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify(data)
|
|
});
|
|
|
|
const result = await res.json();
|
|
if (result.success) {
|
|
window.location.href = '/dashboard';
|
|
} else {
|
|
alert(result.error || 'Error al iniciar sesión');
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|