Using the existing code, hardcore code in an Admin account that is seperate from the regular user accounts. Only when logging in using the Admin account should the page should redirect you to sales.html 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"); } }
Using the existing code, hardcore code in an Admin account that is seperate from the regular user accounts. Only when logging in using the Admin account should the page should redirect you to sales.html
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