home & login page files

This commit is contained in:
Erik 2022-11-11 21:37:37 +02:00
parent b06696f6ff
commit 769f412ecc
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
6 changed files with 152 additions and 0 deletions

28
files/2fa.html Normal file
View File

@ -0,0 +1,28 @@
<!--
This file isn't automatically served anywhere, it's just here to populate the directory
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>2 FA</title>
</head>
<body>
<div class="main-container">
<h2>Verification</h2>
<form action="/api/login/verify" method="post">
<label for="code">Code: </label>
<input id="code" name="code" type="password" required><br />
<input type="submit" value="Verify">
</form>
</div>
</body>
</html>

30
files/finalise.html Normal file
View File

@ -0,0 +1,30 @@
<!--
This file isn't automatically served anywhere, it's just here to populate the directory
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Finalise Account</title>
</head>
<body>
<div class="main-container">
<h2>Finalise account registration</h2>
<form action="/api/register/finalise" method="post">
<label for="username">Username (required): </label>
<input id="username" name="username" type="text" autocomplete="off" required><br />
<label for="password">Password (not required): </label>
<input id="password" name="password" type="password"><br />
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>

30
files/home.html Normal file
View File

@ -0,0 +1,30 @@
<!--
This file isn't automatically served anywhere, it's just here to populate the directory
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Home</title>
</head>
<body>
<div class="main-container">
<h2>Add 2FA</h2>
<img src="/api/user/2fa" />
<form action="/api/user/2fa/verify" method="post">
<label for="code">2FA code</label>
<input type="text" id="code" name="code">
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,24 @@
const { Endpoint } = require("../../interfaces");
class Home extends Endpoint {
constructor (server) {
super(server, {
name: 'home',
path: '/home'
});
this.methods = [
[ 'get', this.home.bind(this), [ server.authenticator.authenticateRedirect ]]
];
}
async home (req, res) {
res.sendFile('/home.html', { root: this.server.serveFiles });
}
}
module.exports = Home;

View File

@ -0,0 +1,40 @@
const { Endpoint } = require("../../interfaces");
class LoginPage extends Endpoint {
constructor (server) {
super(server, {
name: 'loginpage',
path: '/login'
});
this.methods = [
[ 'get', this.login.bind(this) ]
];
this.subpaths = [
[ '/fail', 'get', this.failed.bind(this) ],
[ '/finalise', 'get', this.finalise.bind(this) ],
[ '/verify', 'get', this.verify.bind(this) ],
];
}
login (req, res) {
res.sendFile('login.html', { root: this.server.serveFiles });
}
finalise (req, res) { // Finalise account registration
res.sendFile('finalise.html', { root: this.server.serveFiles });
}
verify (req, res) { // Finalise account registration
res.sendFile('2fa.html', { root: this.server.serveFiles });
}
failed (req, res) {
res.status(401).send('Login failed');
}
}
module.exports = LoginPage;