rithwikreal's picture
Update script.js
168404c verified
// Fixed credentials
const FIXED_USERNAME = "people";
const FIXED_PASSWORD = "home";
// Protect app.html
if (window.location.pathname.includes("app.html")) {
if (!sessionStorage.getItem("isLoggedIn")) {
window.location.href = "index.html";
}
}
// Login function
function login() {
const user = document.getElementById("username").value;
const pass = document.getElementById("password").value;
const message = document.getElementById("message");
if (user === FIXED_USERNAME && pass === FIXED_PASSWORD) {
sessionStorage.setItem("isLoggedIn", "true");
window.location.href = "app.html";
} else {
message.innerText = "❌ Invalid username or password";
}
}
// Logout
function logout() {
sessionStorage.removeItem("isLoggedIn");
window.location.href = "index.html";
}
// Disable signup (optional safety)
function signup() {
alert("Signup is disabled. Use the provided demo credentials.");
}