Edit the existing code to add an admin account that is seperate from the regular user accounts. When logging in using the admin account, 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"); } }
Edit the existing code to add an admin account that is seperate from the regular user accounts. When logging in using the admin account, 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 with 6 images