Create an admin account with a username and password that is seperate from the regular user accounts, only the admin should be able to see the Sales-graph, so when the admin logins, redirect them only to a sales.html page. You will need to hardcode this in your login script. Do not use window.location for redirection. Existing code: login.html Login User Name: User Pass: 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 storedUserName = localStorage.getItem("UserName"); var storedPassword = localStorage.getItem("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"); } } function setUserNameAndPassOnStorage() { var userName = document.getElementById("txtUserName").value; var password = document.getElementById("txtPassword").value; if (userName.length > 0 && password.length > 0) { localStorage.setItem("UserName", userName); localStorage.setItem("Password", password); alert("Password Reset successfully"); } else { alert("username or password should not be blank"); } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Create an admin account with a username and password that is seperate from the regular user accounts, only the admin should be able to see the Sales-graph, so when the admin logins, redirect them only to a sales.html page. You will need to hardcode this in your login script. Do not use window.location for redirection.

Existing code:

login.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Login</title>
<script src="./js/login.js"></script>
</head>
<body>
<div>
User Name: <input type="text" width="200" id="txtUserName" /><br />
User Pass: <input type="text" width="200" id="txtPassword" /><br />
<input type="button" value="Login" width="200" onclick="LoginUser()" />
<input type="button" value="Reset Password Page" width="200" onclick="ResetPassword()" />
</div>
</body>
</html>

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 storedUserName = localStorage.getItem("UserName");
var storedPassword = localStorage.getItem("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");
}
}

function setUserNameAndPassOnStorage() {

var userName = document.getElementById("txtUserName").value;
var password = document.getElementById("txtPassword").value;

if (userName.length > 0 && password.length > 0) {
localStorage.setItem("UserName", userName);
localStorage.setItem("Password", password);
alert("Password Reset successfully");
} else {
alert("username or password should not be blank");
}
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY