Site protegido com um Log-in
This commit is contained in:
4
sitecomlogin/accounts.csv
Normal file
4
sitecomlogin/accounts.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
email,senha
|
||||
usuario1@example.com,senha123
|
||||
usuario2@example.com,senha456
|
||||
usuario3@example.com,senha789
|
||||
|
18
sitecomlogin/index.html
Normal file
18
sitecomlogin/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-br">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Formulário de Login</h1>
|
||||
<input placeholder="Email" id="emailUsuario">
|
||||
<input type="password" placeholder="Senha" id="senhaUsuario">
|
||||
<button onclick="login()">Entrar</button>
|
||||
|
||||
<script src="script.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
13
sitecomlogin/indextwo.html
Normal file
13
sitecomlogin/indextwo.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-br">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Página Protegida</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Bem-vindo</h1>
|
||||
<p>Conteúdo restrito apenas para usuários autorizados.</p>
|
||||
<img width="400" src="https://img.ifunny.co/images/e2ec6f8e3913f2c6763d09eb3f8e5075857a33751aaf1452297a35e2cff712ff_1.jpg">
|
||||
</body>
|
||||
</html>
|
||||
22
sitecomlogin/script.js
Normal file
22
sitecomlogin/script.js
Normal 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 = '';
|
||||
}
|
||||
}
|
||||
22
sitecomlogin/style.css
Normal file
22
sitecomlogin/style.css
Normal file
@@ -0,0 +1,22 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
input, button {
|
||||
margin: 10px;
|
||||
padding: 8px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
Reference in New Issue
Block a user