complete basic login logic.
This commit is contained in:
parent
4460c6fd9f
commit
ec03f7a713
@ -9,6 +9,7 @@
|
|||||||
<div class="whole-wrapper">
|
<div class="whole-wrapper">
|
||||||
<h1 class="tes">Logged in.</h1>
|
<h1 class="tes">Logged in.</h1>
|
||||||
<a class="back-home" href="/">Back home</a>
|
<a class="back-home" href="/">Back home</a>
|
||||||
|
<a class="logout-link" href="/log-out">Log Out</a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
14
pages/logout.html
Normal file
14
pages/logout.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Logged Out</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../styles/styles.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="whole-wrapper">
|
||||||
|
<h1 class="title">Logged Out</h1>
|
||||||
|
<a class="back-landing" href="/">Go Back To Landing</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
14
pages/wronginfo.html
Normal file
14
pages/wronginfo.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Wrong info</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../styles/styles.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="whole-wrapper">
|
||||||
|
<h1 class="wrong-info-message">Wrong Information entered; please try again.</h1>
|
||||||
|
<a class="back-home" href="/">Go Back to the Landing Page.</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
23
server.js
23
server.js
@ -22,7 +22,6 @@ const server = http.createServer((req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (req.url === "/") {
|
if (req.url === "/") {
|
||||||
logged = "false";
|
|
||||||
res.statusCode = 200;
|
res.statusCode = 200;
|
||||||
res.setHeader("Content-Type", "text/html");
|
res.setHeader("Content-Type", "text/html");
|
||||||
fs.readFile("pages/landing.html", function(error, data) {
|
fs.readFile("pages/landing.html", function(error, data) {
|
||||||
@ -52,6 +51,12 @@ const server = http.createServer((req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.url === "/" && logged === "true") {
|
||||||
|
res.statusCode = 200;
|
||||||
|
res.writeHead(301, { Location: "/home" });
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
|
||||||
if (req.url === "/wrong_info") {
|
if (req.url === "/wrong_info") {
|
||||||
res.statusCode = 200;
|
res.statusCode = 200;
|
||||||
res.setHeader("Content-Type", "text/html");
|
res.setHeader("Content-Type", "text/html");
|
||||||
@ -67,6 +72,22 @@ const server = http.createServer((req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.url === "/log-out") {
|
||||||
|
logged = "false";
|
||||||
|
res.statusCode = 200;
|
||||||
|
res.setHeader("Content-Type", "text/html");
|
||||||
|
fs.readFile("pages/logout.html", function(error, data) {
|
||||||
|
if (error) {
|
||||||
|
res.writeHead(404);
|
||||||
|
res.write("Error: File not found.");
|
||||||
|
} else {
|
||||||
|
res.write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (req.url === "/members" && req.method === "POST") {
|
if (req.url === "/members" && req.method === "POST") {
|
||||||
res.statusCode = 200;
|
res.statusCode = 200;
|
||||||
//res.setHeader("Content-Type", "text/json");
|
//res.setHeader("Content-Type", "text/json");
|
||||||
|
Loading…
Reference in New Issue
Block a user