33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const formulario = document.getElementById('formularioLogin');
|
|
const notificacion = document.getElementById('mensaje');
|
|
|
|
formulario.addEventListener('submit', async (event) => {
|
|
|
|
event.preventDefault();
|
|
const usuario = document.getElementById("user").value;
|
|
const password = document.getElementById("pw").value;
|
|
|
|
const data = new FormData();
|
|
data.append('usuario', usuario);
|
|
data.append('password', password);
|
|
|
|
try {
|
|
|
|
const respuestaPeticion = await fetch('controladores/login.php', {
|
|
method: 'POST',
|
|
body: data
|
|
});
|
|
const verificarCredenciales = await respuestaPeticion.json();
|
|
if (verificarCredenciales.loginExitoso) {
|
|
window.location.href = 'ventanaConciertos.html';
|
|
} else {
|
|
notificacion.textContent ="Usuario o contraseña incorrecta";
|
|
notificacion.style.color='#ffffff';
|
|
}
|
|
} catch (error) {
|
|
console.error(error);
|
|
notificacion.textContent = 'Lo sentimos, el servicio no está disponible por el momento.';
|
|
notificacion.style.color = '#ff0000';
|
|
}
|
|
});
|