Create an admin account that is separate from the regular users. Only the admin should be able to see the Sales-graph. So when the admin logins, redirect them only to the sales.html page. The admin’s username should be something like admin@example.com and their password can be something like “password123”. You will need to hardcode this in your login script. Do not use windows.location for redirection. Existing code: login.js function Login() { window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + "/Login.html" } function ResetPassword() { window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + "/resetpassword.html" } function LoginUser() { var userName = document.getElementById("txtUserName").value; var password = document.getElementById("txtPassword").value; var user = JSON.parse(localStorage.getItem("user")); var storedUserName = user.email; var storedPassword = user.password; if (storedUserName && storedPassword) { if (userName.length > 0 && password.length > 0) { if (userName == storedUserName && password == storedPassword) { alert("Logged In"); } else { alert("username or password does not match and try again"); } } else { alert("username or password should not be blank"); } } else { alert("username or password does not match and try again"); } }
Create an admin account that is separate from the regular users. Only the admin should be able to see the Sales-graph. So when the admin logins, redirect them only to the sales.html page. The admin’s username should be something like admin@example.com and their password can be something like “password123”. You will need to hardcode this in your login script. Do not use windows.location for redirection.
Existing code:
login.js
function Login() {
window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + "/Login.html"
}
function ResetPassword() {
window.location.href = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + "/resetpassword.html"
}
function LoginUser() {
var userName = document.getElementById("txtUserName").value;
var password = document.getElementById("txtPassword").value;
var user = JSON.parse(localStorage.getItem("user"));
var storedUserName = user.email;
var storedPassword = user.password;
if (storedUserName && storedPassword) {
if (userName.length > 0 && password.length > 0) {
if (userName == storedUserName && password == storedPassword) {
alert("Logged In");
} else {
alert("username or password does not match and try again");
}
} else {
alert("username or password should not be blank");
}
} else {
alert("username or password does not match and try again");
}
}
Step by step
Solved in 2 steps with 6 images