-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (27 loc) · 1.05 KB
/
Copy pathscript.js
File metadata and controls
32 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function login() {
const predefinedUsername = "Fanyzinha";
const predefinedPassword = "chicocoins";
const usernameInput = document.getElementById("username").value;
const passwordInput = document.getElementById("password").value;
if (usernameInput === predefinedUsername && passwordInput === predefinedPassword) {
// Store login status in localStorage
localStorage.setItem("isLoggedIn", "true");
// Redirect to dashboard.html on successful login
window.location.href = "./dashboard.html";
} else {
alert("Nome de usuário ou senha incorretos. Tente novamente.");
}
}
function checkLogin() {
if (localStorage.getItem("isLoggedIn") !== "true") {
window.location.href = "./index.html";
}
}
function logout() {
localStorage.removeItem("isLoggedIn");
window.location.href = "./index.html";
}
document.querySelector(".login-form").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent form submission
login();
});