Site protegido com um Log-in

This commit is contained in:
SynthX7
2024-06-16 00:36:48 -03:00
committed by GitHub
parent 0872bd4ce6
commit 1f33abd9ad
5 changed files with 79 additions and 0 deletions

22
sitecomlogin/script.js Normal file
View File

@@ -0,0 +1,22 @@
async function login() {
const email = document.getElementById("emailUsuario").value.toLowerCase();
const senha = document.getElementById("senhaUsuario").value;
const response = await fetch('accounts.csv');
const text = await response.text();
const parsedCSV = Papa.parse(text, { header: true });
const usuarios = parsedCSV.data;
const usuarioAutenticado = usuarios.find(usuario => {
return usuario.email.toLowerCase() === email && usuario.senha === senha;
});
if (usuarioAutenticado) {
window.location.href = "indextwo.html";
} else {
alert("Email ou senha incorretos. Por favor, tente novamente.");
document.getElementById("emailUsuario").value = '';
document.getElementById("senhaUsuario").value = '';
}
}