changed login from hard coded to json based. Minor css changes.
This commit is contained in:
parent
f2b3318e6c
commit
c9bc4d6eb5
15
pages/wrongInfo.html
Normal file
15
pages/wrongInfo.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Try Again.</title>
|
||||
<link rel="stylesheet" type="text/css" href="./../styles/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="whole-wrapper">
|
||||
<h1 class="error-content">Wrong username and/or password. <br/><br/>
|
||||
Please try again.</h1><br/><br/>
|
||||
<a class="return-link" href="/">Return home.</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
22
server.js
22
server.js
@ -1,6 +1,7 @@
|
||||
const http = require("http");
|
||||
const fs = require("fs");
|
||||
const qs = require("querystring");
|
||||
const json = require("./data/accounts.json");
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
if (req.url === "/styles/styles.css") {
|
||||
@ -50,7 +51,7 @@ const server = http.createServer((req, res) => {
|
||||
|
||||
if (req.method === "POST" && req.url === "/members") {
|
||||
res.statusCode = 200;
|
||||
res.setHeader("Content-Type", "text/html");
|
||||
res.setHeader("Content-Type", "text/json");
|
||||
var body = "";
|
||||
|
||||
req.on("data", function(data) {
|
||||
@ -59,10 +60,10 @@ const server = http.createServer((req, res) => {
|
||||
|
||||
req.on("end", function() {
|
||||
var post = qs.parse(body);
|
||||
if (post.username === "sweatshirt" && post.password === "Daemons0!") {
|
||||
if (post.username === json[0].username && post.password === json[0].password) {
|
||||
res.writeHead(301, { Location: "/sweatshirt" });
|
||||
} else {
|
||||
res.write("try again.");
|
||||
res.writeHead(301, { Location: "/wrongInfo" });
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
@ -84,6 +85,21 @@ const server = http.createServer((req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (req.url === "/wrongInfo") {
|
||||
res.statusCode = 200;
|
||||
res.setHeader("Content-Type", "text/html");
|
||||
fs.readFile("./pages/wrongInfo.html", function(error, data) {
|
||||
if (error) {
|
||||
res.writeHead(404);
|
||||
res.write("Error: File not found.");
|
||||
} else {
|
||||
res.write(data);
|
||||
}
|
||||
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
const port = process.env.port || 8080;
|
||||
|
@ -95,17 +95,20 @@ body {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 15px;
|
||||
width: 500px;
|
||||
box-shadow: 5px 5px 5px lightgrey;
|
||||
}
|
||||
|
||||
.updates-title {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
.update-content {
|
||||
position: relative;
|
||||
margin-left: 10px;
|
||||
color: blue;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
@ -118,6 +121,16 @@ body {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.error-content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.return-link {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.topics-board-wrapper {
|
||||
border: 1px solid black;
|
||||
padding: 25px;
|
||||
|
Loading…
Reference in New Issue
Block a user