very elementary login logic.
This commit is contained in:
parent
71725052e9
commit
3e063ff15f
7
auth/varification.js
Normal file
7
auth/varification.js
Normal file
@ -0,0 +1,7 @@
|
||||
var username = document.getElementByName("username").value;
|
||||
var password = document.getElementByName("password").value;
|
||||
|
||||
module.exports = {
|
||||
username,
|
||||
password
|
||||
}
|
7
data/accounts.json
Normal file
7
data/accounts.json
Normal file
@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"username": "sweatshirt",
|
||||
"password": "Daemons0!"
|
||||
}
|
||||
]
|
9
node_modules/.package-lock.json
generated
vendored
9
node_modules/.package-lock.json
generated
vendored
@ -271,6 +271,15 @@
|
||||
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/querystring": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz",
|
||||
"integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==",
|
||||
"deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/readdirp": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
||||
|
42
node_modules/querystring/CHANGELOG.md
generated
vendored
Normal file
42
node_modules/querystring/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.2.1](https://github.com/Gozala/querystring/compare/v0.2.0...v0.2.1) (2021-02-15)
|
||||
|
||||
_Maintanance update_
|
||||
|
||||
## [0.2.0] - 2013-02-21
|
||||
|
||||
### Changed
|
||||
|
||||
- Refactor into function per-module idiomatic style.
|
||||
- Improved test coverage.
|
||||
|
||||
## [0.1.0] - 2011-12-13
|
||||
|
||||
### Changed
|
||||
|
||||
- Minor project reorganization
|
||||
|
||||
## [0.0.3] - 2011-04-16
|
||||
|
||||
### Added
|
||||
|
||||
- Support for AMD module loaders
|
||||
|
||||
## [0.0.2] - 2011-04-16
|
||||
|
||||
### Changed
|
||||
|
||||
- Ported unit tests
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed functionality that depended on Buffers
|
||||
|
||||
## [0.0.1] - 2011-04-15
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release
|
7
node_modules/querystring/LICENSE
generated
vendored
Normal file
7
node_modules/querystring/LICENSE
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright 2012 Irakli Gozalishvili
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
node_modules/querystring/README.md
generated
vendored
Normal file
22
node_modules/querystring/README.md
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
# querystring
|
||||
|
||||
[![NPM](https://img.shields.io/npm/v/querystring.svg)](https://npm.im/querystring)
|
||||
[![gzip](https://badgen.net/bundlephobia/minzip/querystring@latest)](https://bundlephobia.com/result?p=querystring@latest)
|
||||
|
||||
Node's querystring module for all engines.
|
||||
|
||||
_If you want to help with evolution of this package, please see https://github.com/Gozala/querystring/issues/20 PR's welcome!_
|
||||
|
||||
## 🔧 Install
|
||||
|
||||
```sh
|
||||
npm i querystring
|
||||
```
|
||||
|
||||
## 📖 Documentation
|
||||
|
||||
Refer to [Node's documentation for `querystring`](https://nodejs.org/api/querystring.html).
|
||||
|
||||
## 📜 License
|
||||
|
||||
MIT © [Gozala](https://github.com/Gozala)
|
20
node_modules/querystring/decode.d.ts
generated
vendored
Normal file
20
node_modules/querystring/decode.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* parses a URL query string into a collection of key and value pairs
|
||||
*
|
||||
* @param qs The URL query string to parse
|
||||
* @param sep The substring used to delimit key and value pairs in the query string
|
||||
* @param eq The substring used to delimit keys and values in the query string
|
||||
* @param options.decodeURIComponent The function to use when decoding percent-encoded characters in the query string
|
||||
* @param options.maxKeys Specifies the maximum number of keys to parse. Specify 0 to remove key counting limitations default 1000
|
||||
*/
|
||||
export type decodeFuncType = (
|
||||
qs?: string,
|
||||
sep?: string,
|
||||
eq?: string,
|
||||
options?: {
|
||||
decodeURIComponent?: Function;
|
||||
maxKeys?: number;
|
||||
}
|
||||
) => Record<any, unknown>;
|
||||
|
||||
export default decodeFuncType;
|
80
node_modules/querystring/decode.js
generated
vendored
Normal file
80
node_modules/querystring/decode.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
|
||||
// If obj.hasOwnProperty has been overridden, then calling
|
||||
// obj.hasOwnProperty(prop) will break.
|
||||
// See: https://github.com/joyent/node/issues/1707
|
||||
function hasOwnProperty(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
||||
|
||||
module.exports = function(qs, sep, eq, options) {
|
||||
sep = sep || '&';
|
||||
eq = eq || '=';
|
||||
var obj = {};
|
||||
|
||||
if (typeof qs !== 'string' || qs.length === 0) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
var regexp = /\+/g;
|
||||
qs = qs.split(sep);
|
||||
|
||||
var maxKeys = 1000;
|
||||
if (options && typeof options.maxKeys === 'number') {
|
||||
maxKeys = options.maxKeys;
|
||||
}
|
||||
|
||||
var len = qs.length;
|
||||
// maxKeys <= 0 means that we should not limit keys count
|
||||
if (maxKeys > 0 && len > maxKeys) {
|
||||
len = maxKeys;
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var x = qs[i].replace(regexp, '%20'),
|
||||
idx = x.indexOf(eq),
|
||||
kstr, vstr, k, v;
|
||||
|
||||
if (idx >= 0) {
|
||||
kstr = x.substr(0, idx);
|
||||
vstr = x.substr(idx + 1);
|
||||
} else {
|
||||
kstr = x;
|
||||
vstr = '';
|
||||
}
|
||||
|
||||
k = decodeURIComponent(kstr);
|
||||
v = decodeURIComponent(vstr);
|
||||
|
||||
if (!hasOwnProperty(obj, k)) {
|
||||
obj[k] = v;
|
||||
} else if (Array.isArray(obj[k])) {
|
||||
obj[k].push(v);
|
||||
} else {
|
||||
obj[k] = [obj[k], v];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
18
node_modules/querystring/encode.d.ts
generated
vendored
Normal file
18
node_modules/querystring/encode.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* It serializes passed object into string
|
||||
* The numeric values must be finite.
|
||||
* Any other input values will be coerced to empty strings.
|
||||
*
|
||||
* @param obj The object to serialize into a URL query string
|
||||
* @param sep The substring used to delimit key and value pairs in the query string
|
||||
* @param eq The substring used to delimit keys and values in the query string
|
||||
* @param name
|
||||
*/
|
||||
export type encodeFuncType = (
|
||||
obj?: Record<any, unknown>,
|
||||
sep?: string,
|
||||
eq?: string,
|
||||
name?: any
|
||||
) => string;
|
||||
|
||||
export default encodeFuncType;
|
64
node_modules/querystring/encode.js
generated
vendored
Normal file
64
node_modules/querystring/encode.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
|
||||
var stringifyPrimitive = function(v) {
|
||||
switch (typeof v) {
|
||||
case 'string':
|
||||
return v;
|
||||
|
||||
case 'boolean':
|
||||
return v ? 'true' : 'false';
|
||||
|
||||
case 'number':
|
||||
return isFinite(v) ? v : '';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function(obj, sep, eq, name) {
|
||||
sep = sep || '&';
|
||||
eq = eq || '=';
|
||||
if (obj === null) {
|
||||
obj = undefined;
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
return Object.keys(obj).map(function(k) {
|
||||
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
||||
if (Array.isArray(obj[k])) {
|
||||
return obj[k].map(function(v) {
|
||||
return ks + encodeURIComponent(stringifyPrimitive(v));
|
||||
}).join(sep);
|
||||
} else {
|
||||
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
||||
}
|
||||
}).filter(Boolean).join(sep);
|
||||
|
||||
}
|
||||
|
||||
if (!name) return '';
|
||||
return encodeURIComponent(stringifyPrimitive(name)) + eq +
|
||||
encodeURIComponent(stringifyPrimitive(obj));
|
||||
};
|
8
node_modules/querystring/index.d.ts
generated
vendored
Normal file
8
node_modules/querystring/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import decodeFuncType from "./decode";
|
||||
import encodeFuncType from "./encode";
|
||||
|
||||
export const decode: decodeFuncType;
|
||||
export const parse: decodeFuncType;
|
||||
|
||||
export const encode: encodeFuncType;
|
||||
export const stringify: encodeFuncType;
|
4
node_modules/querystring/index.js
generated
vendored
Normal file
4
node_modules/querystring/index.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
exports.decode = exports.parse = require('./decode');
|
||||
exports.encode = exports.stringify = require('./encode');
|
35
node_modules/querystring/package.json
generated
vendored
Normal file
35
node_modules/querystring/package.json
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "querystring",
|
||||
"id": "querystring",
|
||||
"version": "0.2.1",
|
||||
"description": "Node's querystring module for all engines.",
|
||||
"keywords": [
|
||||
"commonjs",
|
||||
"query",
|
||||
"querystring"
|
||||
],
|
||||
"author": "Irakli Gozalishvili <rfobic@gmail.com>",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Gozala/querystring.git",
|
||||
"web": "https://github.com/Gozala/querystring"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/Gozala/querystring/issues/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"test": "~0.x.0",
|
||||
"retape": "~0.x.0",
|
||||
"tape": "~0.1.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "npm run test-node && npm run test-tap",
|
||||
"test-node": "node ./test/common-index.js",
|
||||
"test-tap": "node ./test/tap-index.js"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
17
package-lock.json
generated
17
package-lock.json
generated
@ -8,6 +8,9 @@
|
||||
"name": "376chan",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"querystring": "^0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.20"
|
||||
}
|
||||
@ -293,6 +296,15 @@
|
||||
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/querystring": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz",
|
||||
"integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==",
|
||||
"deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/readdirp": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
||||
@ -584,6 +596,11 @@
|
||||
"integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
|
||||
"dev": true
|
||||
},
|
||||
"querystring": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz",
|
||||
"integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg=="
|
||||
},
|
||||
"readdirp": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
||||
|
@ -5,12 +5,15 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"dev": "nodemon server.js"
|
||||
"dev": "nodemon server.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.20"
|
||||
},
|
||||
"dependencies": {
|
||||
"querystring": "^0.2.1"
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="./../styles/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="javascript" href="../auth/varification.js" ></script>
|
||||
<div class="whole-wrapper">
|
||||
<div class="nav-wrapper">
|
||||
<a class="home-link" href="/">Home</a>
|
||||
@ -18,9 +19,9 @@
|
||||
<p class="home-subtitle">The sapiocentric imageboard.</p>
|
||||
</div>
|
||||
<div class="login-wrapper">
|
||||
<form action="./../sys/login.js" method="POST" class="login">
|
||||
<input type="text" class="username" id="username" placeholder="Username" /><br/><br/>
|
||||
<input class="password" type="password" id="password" placeholder="Password" /><br/><br/>
|
||||
<form action="/members" method="POST" class="login">
|
||||
<input type="text" class="username" name="username" placeholder="Username" /><br/><br/>
|
||||
<input class="password" type="password" name="password" placeholder="Password" /><br/><br/>
|
||||
<input type="submit" class="login-button" value="Log in" />
|
||||
</form>
|
||||
</div>
|
||||
|
14
pages/sweatshirt.html
Normal file
14
pages/sweatshirt.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Welcome, Sweatshirt!</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="whole-wrapper">
|
||||
<div class="title-wrapper">
|
||||
<h1 class="title">Welcome Sweatshirt</h1>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
39
server.js
39
server.js
@ -1,5 +1,6 @@
|
||||
const http = require("http");
|
||||
const fs = require("fs");
|
||||
const qs = require("querystring");
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
if (req.url === "/styles/styles.css") {
|
||||
@ -46,6 +47,44 @@ const server = http.createServer((req, res) => {
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
|
||||
if (req.method === "POST" && req.url === "/members") {
|
||||
res.statusCode = 200;
|
||||
res.setHeader("Content-Type", "text/html");
|
||||
var body = "";
|
||||
|
||||
req.on("data", function(data) {
|
||||
body = body + data;
|
||||
});
|
||||
|
||||
req.on("end", function() {
|
||||
var post = qs.parse(body);
|
||||
if (post.username === "sweatshirt" && post.password === "Daemons0!") {
|
||||
res.writeHead(301, { Location: "/sweatshirt" });
|
||||
//res.end();
|
||||
} else {
|
||||
res.write("try again.");
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (req.url === "/sweatshirt") {
|
||||
res.statusCode = 200;
|
||||
res.setHeader("Content-Type", "text/html");
|
||||
fs.readFile("./pages/sweatshirt.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;
|
||||
|
@ -17,6 +17,10 @@ body {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.nav-wrapper a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.home-title {
|
||||
font-size: 1.7rem;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user