mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-16 23:02:13 +11:00
fix
This commit is contained in:
parent
4503647be0
commit
164def2634
31 changed files with 20 additions and 4416 deletions
24
ccashfrontend/.gitignore
vendored
24
ccashfrontend/.gitignore
vendored
|
|
@ -1,24 +0,0 @@
|
||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
||||||
|
|
||||||
# dependencies
|
|
||||||
/node_modules
|
|
||||||
/.pnp
|
|
||||||
.pnp.js
|
|
||||||
|
|
||||||
# testing
|
|
||||||
/coverage
|
|
||||||
|
|
||||||
# production
|
|
||||||
/build
|
|
||||||
|
|
||||||
# misc
|
|
||||||
.DS_Store
|
|
||||||
.env
|
|
||||||
.env.local
|
|
||||||
.env.development.local
|
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
# syntax=docker/dockerfile:1
|
|
||||||
FROM keymetrics/pm2:16-buster
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
RUN npm install
|
|
||||||
CMD [ "pm2-runtime", "start", "pm2.json", "--watch"]
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
# ccashfrontend
|
|
||||||
This is a Front End for EntireTwix's CCcash API, it allows regular users to access the banks features and do what they like without having to know code or http requests.
|
|
||||||
|
|
||||||
## Deployment
|
|
||||||
To begin you must have set up CCash API server which you can find here [Github](https://github.com/EntireTwix/CCash) He is much better at documentation than i, but his is also harder to set up so good luck.
|
|
||||||
|
|
||||||
From here is will assume you have set up the api server, know its URL and what protocol it is using
|
|
||||||
|
|
||||||
if deploying to a serverless application make sure you set the environmental variables first. these are as follows
|
|
||||||
* BANKAPIURL=your api url including http/s and the trailing slash NOT BANKF
|
|
||||||
* SECURE=true if you have ssl on your front end host
|
|
||||||
* SETUP=true when you have set the above this just gets rid of the setup page that will show if it equals false or the .env file is not found
|
|
||||||
* PORT=Optional will default to 3000 if not set
|
|
||||||
|
|
||||||
if you are deploying on a vps then
|
|
||||||
1. git clone repository
|
|
||||||
2. run npm install
|
|
||||||
3. Set environmental variables (they are no longer set through the webpage) hint: make a .env file in the root and fill in environmental variables as above
|
|
||||||
4. run with your favourite node webserver if you dont know any use [pm2](https://pm2.keymetrics.io/)
|
|
||||||
5. restart the application and badda bim badda boom you done
|
|
||||||
|
|
||||||
If you want to properly deploy it put it behind a reverse proxy too so you can have virtual hosts and all that shizzaz
|
|
||||||
but im not going to outline that because that is more advanced, and will require a lot of explaining, google `how to reverse proxy a nodejs app` if you want to know more
|
|
||||||
|
|
||||||
|
|
||||||
## Credits
|
|
||||||
https://github.com/LukeeeeBennett/ccash-client-js - API (started using his api because it makes my code cleaner though as of writing this it needs a few changes to work but should be fixed within 24ish hours ive made a pull request)
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
checkAdmin: function (req, res, next) {
|
|
||||||
if (req.session.admin != false) {
|
|
||||||
if (req.session.admin != undefined) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
req.flash("error_msg", "admins only");
|
|
||||||
res.redirect("/");
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
ensureAuthenticated: function (req, res, next) {
|
|
||||||
if (req.session.user != undefined) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
req.session.errors = [];
|
|
||||||
req.session.errors.push({ msg: "please login to view this resource" });
|
|
||||||
res.redirect("/login");
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
const { CCashClient } = require("ccash-client-js");
|
|
||||||
|
|
||||||
async function postUser(name, password) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
console.log(process.env.BANKAPIURL);
|
|
||||||
try {
|
|
||||||
return await client.addUser(name, password);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { postUser };
|
|
||||||
|
|
@ -1,352 +0,0 @@
|
||||||
const root = process.env.PWD;
|
|
||||||
const express = require("express");
|
|
||||||
const path = require("path");
|
|
||||||
const https = require("https");
|
|
||||||
const got = require("got");
|
|
||||||
const bodyParser = require("body-parser");
|
|
||||||
const expressValidator = require("express-validator");
|
|
||||||
const flash = require("connect-flash");
|
|
||||||
const session = require("express-session");
|
|
||||||
const { ensureAuthenticated } = require(`${root}/config/auth.js`);
|
|
||||||
const app = express();
|
|
||||||
const MemoryStore = require("memorystore")(session);
|
|
||||||
const url = require("url");
|
|
||||||
const dotenv = require("dotenv");
|
|
||||||
const fs = require("fs");
|
|
||||||
const mongoose = require("mongoose");
|
|
||||||
const { CCashClient } = require("ccash-client-js");
|
|
||||||
dotenv.config();
|
|
||||||
const { postUser } = require(`${root}/helpers/functions.js`);
|
|
||||||
|
|
||||||
app.set("views", path.join(__dirname, "views"));
|
|
||||||
app.set("view engine", "pug");
|
|
||||||
app.use(flash());
|
|
||||||
app.use(require("connect-flash")());
|
|
||||||
app.use(express.static(path.join(__dirname, "public")));
|
|
||||||
app.use(express.json());
|
|
||||||
app.use(
|
|
||||||
bodyParser.urlencoded({
|
|
||||||
extended: true,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
app.use(function (req, res, next) {
|
|
||||||
res.locals.messages = require("express-messages")(req, res);
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
app.set("trust proxy", 1); // trust first proxy
|
|
||||||
const secure = process.env.SECURE;
|
|
||||||
app.use(
|
|
||||||
session({
|
|
||||||
secret: "fuck shit cunt",
|
|
||||||
resave: true,
|
|
||||||
store: new MemoryStore({
|
|
||||||
checkPeriod: 86400000, // prune expired entries every 24h
|
|
||||||
}),
|
|
||||||
saveUninitialized: true,
|
|
||||||
cookie: { secure: secure, maxAge: 86400000 },
|
|
||||||
})
|
|
||||||
);
|
|
||||||
app.use(
|
|
||||||
expressValidator({
|
|
||||||
errorFormatter: function (param, msg, value) {
|
|
||||||
var namespace = param.split("."),
|
|
||||||
root = namespace.shift(),
|
|
||||||
formParam = root;
|
|
||||||
|
|
||||||
while (namespace.length) {
|
|
||||||
formParam += "[" + namespace.shift() + "]";
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
param: formParam,
|
|
||||||
msg: msg,
|
|
||||||
value: value,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
function papy() {
|
|
||||||
const rndInt = Math.floor(Math.random() * 1337);
|
|
||||||
let random = false;
|
|
||||||
if (rndInt == 420) {
|
|
||||||
random = true;
|
|
||||||
}
|
|
||||||
return random;
|
|
||||||
}
|
|
||||||
|
|
||||||
app.post("/setup", async function (req, res) {
|
|
||||||
const { url, secure } = req.body;
|
|
||||||
if (secure) {
|
|
||||||
process.env.SECURE = true;
|
|
||||||
}
|
|
||||||
process.env.BANKAPIURL = url;
|
|
||||||
console.log(process.env.BANKAPIURL);
|
|
||||||
fs.writeFileSync(
|
|
||||||
".env",
|
|
||||||
"BANKAPIURL=" +
|
|
||||||
process.env.BANKAPIURL +
|
|
||||||
"\n" +
|
|
||||||
"SECURE=" +
|
|
||||||
process.env.SECURE +
|
|
||||||
"\nSETUP=true"
|
|
||||||
);
|
|
||||||
fs.writeFileSync("tmp/restart.txt", "");
|
|
||||||
res.redirect("/");
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/", async function (req, res) {
|
|
||||||
if (process.env.SETUP == false || !process.env.SETUP) {
|
|
||||||
res.render("setup");
|
|
||||||
} else {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let checkalive;
|
|
||||||
try {
|
|
||||||
checkalive = await client.help();
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
let alive = false;
|
|
||||||
try {
|
|
||||||
if (checkalive) {
|
|
||||||
alive = true;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.render("index", {
|
|
||||||
user: req.session.user,
|
|
||||||
admin: req.session.admin,
|
|
||||||
alive: alive,
|
|
||||||
url: process.env.BANKAPIURL,
|
|
||||||
random: papy(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
app.get("/BankF", ensureAuthenticated, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let successes = req.session.successes;
|
|
||||||
let errors = req.session.errors;
|
|
||||||
req.session.errors = [];
|
|
||||||
let admin;
|
|
||||||
try {
|
|
||||||
admin = req.session.admin;
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
let balance = 0;
|
|
||||||
try {
|
|
||||||
balance = await client.balance(req.session.user);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
let logsent;
|
|
||||||
console.log("start " + Date.now());
|
|
||||||
try {
|
|
||||||
const { user, password } = req.session;
|
|
||||||
logsent = await client.log(user, password);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
console.log(logsent);
|
|
||||||
let logrec = logsent;
|
|
||||||
let graphlog = logsent;
|
|
||||||
if (graphlog != null) {
|
|
||||||
graphlog = graphlog.reverse();
|
|
||||||
}
|
|
||||||
let graphdata = "";
|
|
||||||
let currentbal = balance;
|
|
||||||
if (graphlog) {
|
|
||||||
for (i = graphlog.length - 1; i > -1; i--) {
|
|
||||||
if (graphlog[i].from == req.session.user) {
|
|
||||||
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
|
||||||
} else {
|
|
||||||
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
graphlog = undefined;
|
|
||||||
}
|
|
||||||
if (graphdata != "") {
|
|
||||||
graphdata =
|
|
||||||
", [" + parseInt(graphlog.length) + "," + balance + "]" + graphdata;
|
|
||||||
graphdata = '["transaction", "balance"]' + graphdata;
|
|
||||||
}
|
|
||||||
if (logsent == null) {
|
|
||||||
logsent = undefined;
|
|
||||||
} else {
|
|
||||||
logsent = await logsent.filter(({ from }) => from === req.session.user);
|
|
||||||
}
|
|
||||||
if (logrec == null) {
|
|
||||||
logrec = undefined;
|
|
||||||
} else {
|
|
||||||
logrec = await logrec.filter(({ to }) => to === req.session.user);
|
|
||||||
}
|
|
||||||
if (logsent) {
|
|
||||||
for (i in logrec) {
|
|
||||||
logrec[i].time = new Date(logrec[i].time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (logrec) {
|
|
||||||
for (i in logsent) {
|
|
||||||
logsent[i].time = new Date(logsent[i].time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (logrec != null) {
|
|
||||||
logrec.reverse();
|
|
||||||
}
|
|
||||||
if (logsent != null) {
|
|
||||||
logsent.reverse();
|
|
||||||
}
|
|
||||||
let maxgraph = balance + 1000;
|
|
||||||
console.log("begin render " + Date.now());
|
|
||||||
res.render("bankf", {
|
|
||||||
maxgraph: maxgraph,
|
|
||||||
graphdata: graphdata,
|
|
||||||
logrec: logrec,
|
|
||||||
logsent: logsent,
|
|
||||||
user: req.session.user,
|
|
||||||
balance: balance,
|
|
||||||
user: req.session.user,
|
|
||||||
admin: req.session.admin,
|
|
||||||
sucesses: successes,
|
|
||||||
errors: errors,
|
|
||||||
random: papy(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post("/sendfunds", async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let { amount, name, senderpass } = req.body;
|
|
||||||
req.session.errors = [];
|
|
||||||
req.session.successes = [];
|
|
||||||
let a_name = req.session.user;
|
|
||||||
let result;
|
|
||||||
result = await client.sendFunds(a_name, senderpass, name, amount);
|
|
||||||
console.log(result);
|
|
||||||
if (result == 1) {
|
|
||||||
req.session.successes.push({ msg: "Transfer successful" });
|
|
||||||
//post details
|
|
||||||
res.redirect("/BankF");
|
|
||||||
} else if (result == -1) {
|
|
||||||
req.session.errors.push({ msg: "Transfer Unsuccessful: User not Found" });
|
|
||||||
res.redirect("/Bankf");
|
|
||||||
} else if (result == -2) {
|
|
||||||
req.session.errors.push({ msg: "Transfer Unsuccessful: Wrong Password" });
|
|
||||||
res.redirect("/Bankf");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post("/register", async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
var { name, password, password2 } = req.body;
|
|
||||||
req.session.errors = [];
|
|
||||||
req.session.successes = [];
|
|
||||||
if (!name || !password || !password2) {
|
|
||||||
req.session.errors.push({ msg: "please fill in all fields" });
|
|
||||||
} else if (password != password2) {
|
|
||||||
req.session.errors.push({ msg: "Passwords don't match" });
|
|
||||||
} else if (password.length < 6) {
|
|
||||||
req.session.errors.push({
|
|
||||||
msg: "Password must be at least 6 characters",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
let checkuser = await postUser(name, password);
|
|
||||||
console.log(checkuser);
|
|
||||||
if (checkuser == -4) {
|
|
||||||
req.session.errors.push({ msg: "Error: Name too long" });
|
|
||||||
res.redirect("/register");
|
|
||||||
} else if (checkuser == -5) {
|
|
||||||
req.session.errors.push({ msg: "Error: User Already Exists" });
|
|
||||||
res.redirect("/register");
|
|
||||||
} else {
|
|
||||||
req.session.successes.push({ msg: "Account Created! please Log in" });
|
|
||||||
res.redirect("/login");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post("/login", async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
if (req.session.user) {
|
|
||||||
res.redirect("/");
|
|
||||||
}
|
|
||||||
req.session.regenerate(function (err) {});
|
|
||||||
const { name, password } = req.body;
|
|
||||||
let adminTest;
|
|
||||||
try {
|
|
||||||
adminTest = await client.adminVerifyPassword(password);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
console.log(adminTest);
|
|
||||||
if (adminTest != -2) {
|
|
||||||
req.session.admin = adminTest;
|
|
||||||
req.session.adminp = password;
|
|
||||||
req.session.user = name;
|
|
||||||
req.session.password = password;
|
|
||||||
res.redirect("/BankF");
|
|
||||||
} else {
|
|
||||||
let verified;
|
|
||||||
verified = await client.verifyPassword(name, password);
|
|
||||||
console.log(verified);
|
|
||||||
if (verified == 1) {
|
|
||||||
req.session.user = name;
|
|
||||||
req.session.password = password;
|
|
||||||
res.redirect("/BankF");
|
|
||||||
} else {
|
|
||||||
req.session.errors = [];
|
|
||||||
req.session.errors.push({ msg: "Password wrong" });
|
|
||||||
res.redirect("/login");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let admin = require("./routes/admin");
|
|
||||||
app.use("/admin", admin);
|
|
||||||
|
|
||||||
let settings = require("./routes/settings");
|
|
||||||
app.use("/settings", settings);
|
|
||||||
|
|
||||||
app.get("/logout", function (req, res) {
|
|
||||||
req.session.regenerate(function (err) {
|
|
||||||
res.render("login", {
|
|
||||||
random: papy(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/login", function (req, res) {
|
|
||||||
let successes = req.session.successes;
|
|
||||||
let errors = req.session.errors;
|
|
||||||
req.session.regenerate(function (err) {
|
|
||||||
res.render("login", {
|
|
||||||
successes: successes,
|
|
||||||
errors: errors,
|
|
||||||
user: req.session.user,
|
|
||||||
random: papy(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/register", function (req, res) {
|
|
||||||
let successes = req.session.successes;
|
|
||||||
req.session.successes = [];
|
|
||||||
let errors = req.session.errors;
|
|
||||||
req.session.errors = [];
|
|
||||||
res.render("register", {
|
|
||||||
errors: errors,
|
|
||||||
successes: successes,
|
|
||||||
user: req.session.user,
|
|
||||||
admin: req.session.admin,
|
|
||||||
random: papy(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
process.on("SIGINT", function () {
|
|
||||||
process.exit();
|
|
||||||
});
|
|
||||||
app.listen(process.env.PORT || 3000, function () {
|
|
||||||
console.log("Server started on port 3000...");
|
|
||||||
});
|
|
||||||
3060
ccashfrontend/package-lock.json
generated
3060
ccashfrontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,39 +0,0 @@
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"ccash-client-js": "^1.6.3",
|
|
||||||
"connect-flash": "^0.1.1",
|
|
||||||
"dotenv": "^8.2.0",
|
|
||||||
"express": "^4.17.1",
|
|
||||||
"express-messages": "^1.0.1",
|
|
||||||
"express-session": "^1.17.1",
|
|
||||||
"express-validator": "5.3.1",
|
|
||||||
"got": "^11.8.2",
|
|
||||||
"https": "^1.0.0",
|
|
||||||
"memorystore": "*",
|
|
||||||
"mongoose": "^5.12.5",
|
|
||||||
"path": "^0.12.7",
|
|
||||||
"pug": "^3.0.2",
|
|
||||||
"url": "^0.11.0",
|
|
||||||
"validator": "^13.5.2"
|
|
||||||
},
|
|
||||||
"name": "ccashfrontend",
|
|
||||||
"description": "",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"start": "node index.js"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/Expand-sys/ccashfrontend.git"
|
|
||||||
},
|
|
||||||
"author": "Expand",
|
|
||||||
"license": "ISC",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/Expand-sys/ccashfrontend/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/Expand-sys/ccashfrontend#readme",
|
|
||||||
"engines": {
|
|
||||||
"node": "16.x"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"name": "ccashfrontend",
|
|
||||||
"script": "/app/ccashfrontend/index.js",
|
|
||||||
"watch": "/app/ccashfrontend/tmp/restart.txt",
|
|
||||||
"instances": "1"
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 279 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
|
|
@ -1,129 +0,0 @@
|
||||||
@font-face {
|
|
||||||
font-family: "PapyrusW01";
|
|
||||||
src: url("//db.onlinewebfonts.com/t/a0e1b1883c0cf520e9c50d0cd91cd0d0.eot");
|
|
||||||
src: url("//db.onlinewebfonts.com/t/a0e1b1883c0cf520e9c50d0cd91cd0d0.eot?#iefix")
|
|
||||||
format("embedded-opentype"),
|
|
||||||
url("//db.onlinewebfonts.com/t/a0e1b1883c0cf520e9c50d0cd91cd0d0.woff2")
|
|
||||||
format("woff2"),
|
|
||||||
url("//db.onlinewebfonts.com/t/a0e1b1883c0cf520e9c50d0cd91cd0d0.woff")
|
|
||||||
format("woff"),
|
|
||||||
url("//db.onlinewebfonts.com/t/a0e1b1883c0cf520e9c50d0cd91cd0d0.ttf")
|
|
||||||
format("truetype"),
|
|
||||||
url("//db.onlinewebfonts.com/t/a0e1b1883c0cf520e9c50d0cd91cd0d0.svg#PapyrusW01")
|
|
||||||
format("svg");
|
|
||||||
}
|
|
||||||
|
|
||||||
.main {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: space-around;
|
|
||||||
height: 100vh;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
background: #f4da46;
|
|
||||||
height: 100vh;
|
|
||||||
background-attachment: fixed;
|
|
||||||
}
|
|
||||||
.navbarrr {
|
|
||||||
background: #bc5b0b;
|
|
||||||
}
|
|
||||||
.blue {
|
|
||||||
background: #46cff2;
|
|
||||||
}
|
|
||||||
.container-large {
|
|
||||||
padding-left: 10%;
|
|
||||||
padding-right: 10%;
|
|
||||||
}
|
|
||||||
.col {
|
|
||||||
padding: 0px;
|
|
||||||
padding-left: 0px;
|
|
||||||
padding-right: 0px;
|
|
||||||
}
|
|
||||||
.card {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
.row {
|
|
||||||
margin-left: 0px;
|
|
||||||
margin-right: 0px;
|
|
||||||
}
|
|
||||||
.logo {
|
|
||||||
width: 250px;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
.logs {
|
|
||||||
height: 350px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
flex-grow: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gallery {
|
|
||||||
background-color: white;
|
|
||||||
margin-bottom: 50px;
|
|
||||||
box-shadow: 10px 10px 5px black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-custom {
|
|
||||||
background-color: #130f40;
|
|
||||||
}
|
|
||||||
.button-fixed {
|
|
||||||
bottom: 0;
|
|
||||||
position: fixed;
|
|
||||||
right: 0;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
.fas {
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-black {
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
.text-white {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.form-check-input {
|
|
||||||
margin-left: 0;
|
|
||||||
padding: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="radio"]:checked ~ .reveal-if-active,
|
|
||||||
input[type="checkbox"]:checked ~ .reveal-if-active {
|
|
||||||
opacity: 1;
|
|
||||||
max-height: 100px; /* little bit of a magic number :( */
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6,
|
|
||||||
p,
|
|
||||||
label {
|
|
||||||
font-family: "PapyrusW01";
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.shadow {
|
|
||||||
box-shadow: 5px 10px #888888;
|
|
||||||
}
|
|
||||||
$w: Min(10em, 100%);
|
|
||||||
|
|
||||||
.grid--masonry {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, $w);
|
|
||||||
|
|
||||||
> * {
|
|
||||||
width: $w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
||||||
|
|
||||||
.main {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: space-around;
|
|
||||||
height: 100vh;
|
|
||||||
}
|
|
||||||
body{
|
|
||||||
background: rgb(182,151,255);
|
|
||||||
background: linear-gradient(180deg, rgba(182,151,255,1) 0%, rgba(113,63,230,1) 100%);
|
|
||||||
height:100vh;
|
|
||||||
background-attachment: fixed;
|
|
||||||
}
|
|
||||||
.navbarrr{
|
|
||||||
background: rgb(38,9,108);
|
|
||||||
background: linear-gradient(180deg, rgba(38,9,108,1) 0%, rgba(14,3,40,1) 100%);;
|
|
||||||
}
|
|
||||||
.blue{
|
|
||||||
background: #46cff2;
|
|
||||||
}
|
|
||||||
.container-large{
|
|
||||||
padding-left: 10%;
|
|
||||||
padding-right: 10%;
|
|
||||||
}
|
|
||||||
.col{
|
|
||||||
padding: 0px;
|
|
||||||
padding-left: 0px;
|
|
||||||
padding-right: 0px;
|
|
||||||
}
|
|
||||||
.card{
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
.row{
|
|
||||||
margin-left: 0px;
|
|
||||||
margin-right: 0px;
|
|
||||||
}
|
|
||||||
.logo{
|
|
||||||
width: 250px;
|
|
||||||
background-color:white;
|
|
||||||
}
|
|
||||||
.logs{
|
|
||||||
height:350px;
|
|
||||||
overflow:auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content{ flex-grow: 1; }
|
|
||||||
|
|
||||||
.gallery{
|
|
||||||
background-color: white;
|
|
||||||
margin-bottom: 50px;
|
|
||||||
box-shadow: 10px 10px 5px black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-custom{
|
|
||||||
background-color:#130f40;
|
|
||||||
}
|
|
||||||
.button-fixed{
|
|
||||||
bottom: 0;
|
|
||||||
position: fixed;
|
|
||||||
right: 0;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
.fas{
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
p{
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-black{
|
|
||||||
color:black;
|
|
||||||
}
|
|
||||||
.text-white{
|
|
||||||
color:white;
|
|
||||||
}
|
|
||||||
.form-check-input{
|
|
||||||
margin-left:0;
|
|
||||||
padding:inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="radio"]:checked ~ .reveal-if-active,
|
|
||||||
input[type="checkbox"]:checked ~ .reveal-if-active {
|
|
||||||
opacity: 1;
|
|
||||||
max-height: 100px; /* little bit of a magic number :( */
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6, p, label{
|
|
||||||
font-family: 'Montserrat', sans-serif;
|
|
||||||
color
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
h1{
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.shadow{
|
|
||||||
box-shadow: 5px 10px #888888;
|
|
||||||
}
|
|
||||||
$w: Min(10em, 100%);
|
|
||||||
|
|
||||||
.grid--masonry {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, $w);
|
|
||||||
|
|
||||||
> * { width: $w; }
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 279 KiB |
|
|
@ -1,13 +0,0 @@
|
||||||
$(document).ready(function(){
|
|
||||||
$("#transactions a").click(function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
$(this).tab('show');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
$("#market a").click(function(e){
|
|
||||||
e.preventDefault();
|
|
||||||
$(this).tab('show');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
||||||
const root = process.env.PWD;
|
|
||||||
const express = require("express");
|
|
||||||
const router = express.Router();
|
|
||||||
const path = require("path");
|
|
||||||
const { ensureAuthenticated } = require(`${root}/config/auth.js`);
|
|
||||||
const { checkAdmin } = require(`${root}/config/admin.js`);
|
|
||||||
const pug = require("pug");
|
|
||||||
const flash = require("connect-flash");
|
|
||||||
const expressValidator = require("express-validator");
|
|
||||||
const session = require("express-session");
|
|
||||||
const { postUser } = require(`${root}/helpers/functions.js`);
|
|
||||||
const got = require("got");
|
|
||||||
const MemoryStore = require("memorystore")(session);
|
|
||||||
const fs = require("fs");
|
|
||||||
const mongoose = require("mongoose");
|
|
||||||
|
|
||||||
const { CCashClient } = require("ccash-client-js");
|
|
||||||
|
|
||||||
console.log("Sen was here");
|
|
||||||
|
|
||||||
router.get("/", checkAdmin, function (req, res) {
|
|
||||||
let successes = req.session.successes;
|
|
||||||
req.session.successes = [];
|
|
||||||
let errors = req.session.errors;
|
|
||||||
req.session.errors = [];
|
|
||||||
res.render("adminsettings", {
|
|
||||||
user: req.session.user,
|
|
||||||
admin: req.session.admin,
|
|
||||||
errors: errors,
|
|
||||||
successes: successes,
|
|
||||||
marketplace: process.env.MARKETPLACE,
|
|
||||||
random: papy(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/user", checkAdmin, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
req.session.errors = [];
|
|
||||||
req.session.successes = [];
|
|
||||||
let { name, init_pass, init_bal, password2 } = req.body;
|
|
||||||
if (!name || !init_pass || !init_bal || !password2) {
|
|
||||||
req.session.errors.push({ msg: "please fill in all fields" });
|
|
||||||
} else if (init_pass !== password2) {
|
|
||||||
req.session.errors.push({ msg: "Passwords don't match" });
|
|
||||||
} else if (init_pass.length < 6) {
|
|
||||||
req.session.errors.push({
|
|
||||||
msg: "Password must be at least 6 characters",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let post = await client.adminAddUser(
|
|
||||||
name,
|
|
||||||
req.session.adminp,
|
|
||||||
init_pass,
|
|
||||||
parseInt(init_bal)
|
|
||||||
);
|
|
||||||
console.log(post);
|
|
||||||
if (post == -3) {
|
|
||||||
req.session.errors.push({ msg: "Invalid Request" });
|
|
||||||
} else if (post == -4) {
|
|
||||||
req.session.errors.push({ msg: "Name too long" });
|
|
||||||
} else if (post == -5) {
|
|
||||||
req.session.errors.push({ msg: "User already exists" });
|
|
||||||
} else {
|
|
||||||
req.session.successes.push({ msg: "Account Creation Successful" });
|
|
||||||
}
|
|
||||||
res.redirect("/admin");
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/baluser", checkAdmin, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let { name } = req.body;
|
|
||||||
let balance;
|
|
||||||
req.session.successes = [];
|
|
||||||
req.session.errors = [];
|
|
||||||
balance = await client.balance(name);
|
|
||||||
console.log(balance.body);
|
|
||||||
balance = parseInt(balance);
|
|
||||||
if (balance < 0) {
|
|
||||||
req.session.errors.push({ msg: "User not found" });
|
|
||||||
} else {
|
|
||||||
req.session.successes.push({
|
|
||||||
msg: "User: " + name + " has " + balance + " monies",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
res.redirect("/admin");
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/bal", checkAdmin, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let { name, amount } = req.body;
|
|
||||||
let patch;
|
|
||||||
req.session.successes = [];
|
|
||||||
req.session.errors = [];
|
|
||||||
patch = await client.setBalance(name, req.session.adminp, parseInt(amount));
|
|
||||||
console.log(patch);
|
|
||||||
if (patch == -1) {
|
|
||||||
req.session.errors.push({ msg: "User not Found" });
|
|
||||||
} else if (patch == 1) {
|
|
||||||
req.session.successes.push({ msg: "Change Funds Successful" });
|
|
||||||
}
|
|
||||||
res.redirect("/admin");
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/userdelete", checkAdmin, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let { name, attempt } = req.body;
|
|
||||||
if (attempt != req.session.adminp) {
|
|
||||||
req.session.errors.push({ msg: "Wrong Admin Password" });
|
|
||||||
res.redirect("/admin");
|
|
||||||
} else {
|
|
||||||
let deleteUser = client.adminDeleteUser(name, attempt);
|
|
||||||
if (deleteUser == -1) {
|
|
||||||
req.session.errors.push({ msg: "User Deletion Failed, User Not Found" });
|
|
||||||
res.redirect("/admin");
|
|
||||||
} else {
|
|
||||||
req.session.successes.push({ msg: "User Deletion Successful" });
|
|
||||||
res.redirect("/admin");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/destroyallsessions", checkAdmin, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let { attempt } = req.body;
|
|
||||||
let adminTest;
|
|
||||||
req.session.errors = [];
|
|
||||||
try {
|
|
||||||
adminTest = await client.adminVerifyPassword(attempt);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
if (adminTest) {
|
|
||||||
req.sessionStore.clear(function (err) {
|
|
||||||
console.log(err);
|
|
||||||
res.redirect("/");
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
req.session.errors.push({ msg: "failed admin password check" });
|
|
||||||
res.redirect("/admin");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/changebackend", checkAdmin, async function (req, res) {
|
|
||||||
let { url } = req.body;
|
|
||||||
if (!url.endsWith("/")) {
|
|
||||||
url = url + "/";
|
|
||||||
}
|
|
||||||
process.env.BANKAPIURL = url;
|
|
||||||
fs.writeFileSync(
|
|
||||||
`${root}/.env`,
|
|
||||||
"BANKAPIURL=" +
|
|
||||||
process.env.BANKAPIURL +
|
|
||||||
"\n" +
|
|
||||||
"SECURE=" +
|
|
||||||
process.env.SECURE +
|
|
||||||
"\n" +
|
|
||||||
"MARKETPLACE=" +
|
|
||||||
process.env.MARKETPLACE +
|
|
||||||
"\n" +
|
|
||||||
"MONGO=" +
|
|
||||||
process.env.MONGO +
|
|
||||||
"\nSETUP=true"
|
|
||||||
);
|
|
||||||
fs.mkdirSync(`${root}/tmp`);
|
|
||||||
fs.writeFileSync(`${root}tmp/restart.txt`, "");
|
|
||||||
res.redirect("../");
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/close", checkAdmin, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let { attempt } = req.body;
|
|
||||||
let close;
|
|
||||||
close = client.close();
|
|
||||||
res.redirect("../");
|
|
||||||
});
|
|
||||||
function papy() {
|
|
||||||
const rndInt = Math.floor(Math.random() * 1337);
|
|
||||||
let random = false;
|
|
||||||
if (rndInt == 420) {
|
|
||||||
random = true;
|
|
||||||
}
|
|
||||||
return random;
|
|
||||||
}
|
|
||||||
module.exports = router;
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
const root = process.env.PWD;
|
|
||||||
const express = require("express");
|
|
||||||
const router = express.Router();
|
|
||||||
const path = require("path");
|
|
||||||
const { ensureAuthenticated } = require(`${root}/config/auth.js`);
|
|
||||||
const { checkAdmin } = require(`${root}/config/admin.js`);
|
|
||||||
var pug = require("pug");
|
|
||||||
const flash = require("connect-flash");
|
|
||||||
const expressValidator = require("express-validator");
|
|
||||||
const session = require("express-session");
|
|
||||||
const { postUser } = require(`${root}/helpers/functions.js`);
|
|
||||||
const { CCashClient } = require("ccash-client-js");
|
|
||||||
|
|
||||||
router.get("/", ensureAuthenticated, function (req, res) {
|
|
||||||
let successes = req.session.successes;
|
|
||||||
req.session.successes = [];
|
|
||||||
let errors = req.session.errors;
|
|
||||||
req.session.errors = [];
|
|
||||||
|
|
||||||
res.render("settings", {
|
|
||||||
errors: errors,
|
|
||||||
successes: successes,
|
|
||||||
user: req.session.user,
|
|
||||||
admin: req.session.admin,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
router.post("/pass", ensureAuthenticated, async function (req, res) {
|
|
||||||
const client = new CCashClient(process.env.BANKAPIURL);
|
|
||||||
let { attempt, new_pass, password2 } = req.body;
|
|
||||||
let patch;
|
|
||||||
if (attempt == undefined) {
|
|
||||||
attempt = "";
|
|
||||||
}
|
|
||||||
if (!new_pass || !password2) {
|
|
||||||
req.session.errors.push({ msg: "please fill in all fields" });
|
|
||||||
}
|
|
||||||
//check if match
|
|
||||||
if (new_pass != password2) {
|
|
||||||
req.session.errors.push({ msg: "Passwords don't match" });
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if password is more than 6 characters
|
|
||||||
if (new_pass.length < 6) {
|
|
||||||
req.session.errors.push({ msg: "Password must be at least 6 characters" });
|
|
||||||
}
|
|
||||||
if (req.session.errors.length > 0) {
|
|
||||||
console.log(req.session.errors);
|
|
||||||
res.redirect("/settings");
|
|
||||||
} else {
|
|
||||||
patch = await client.changePassword(req.session.user, attempt, new_pass);
|
|
||||||
console.log(patch);
|
|
||||||
if (patch == -2) {
|
|
||||||
req.session.errors.push({
|
|
||||||
msg: "Password Wrong",
|
|
||||||
});
|
|
||||||
res.redirect("/settings");
|
|
||||||
} else {
|
|
||||||
req.session.regenerate(function (err) {
|
|
||||||
req.session.successes = [];
|
|
||||||
req.session.successes.push({
|
|
||||||
msg: "Change Password Successful, Please Login Again",
|
|
||||||
});
|
|
||||||
res.redirect("/login");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = router;
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
extends layout
|
|
||||||
|
|
||||||
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
h1 Settings, logged in as: #{user}
|
|
||||||
if admin == true
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
center
|
|
||||||
h4 here are your settings king
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
h4 Add User
|
|
||||||
form(method='POST', action='/admin/user')
|
|
||||||
#form-group
|
|
||||||
label Username:
|
|
||||||
input.form-control(name='name', type='name')
|
|
||||||
label Starting balance:
|
|
||||||
input.form-control(name='init_bal', type='number')
|
|
||||||
label Password:
|
|
||||||
input.form-control(name='init_pass',type='password')
|
|
||||||
label Confirm:
|
|
||||||
input.form-control(name='password2',type='password')
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit',value='Submit')
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
h4 Check User Balance
|
|
||||||
form(method='POST', action='/admin/baluser')
|
|
||||||
#form-group
|
|
||||||
label Username:
|
|
||||||
input.form-control(name='name', type='name')
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit',value='Submit')
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
h4 Change Balance of User
|
|
||||||
form(method='POST', action='/admin/bal')
|
|
||||||
#form-group
|
|
||||||
label Username:
|
|
||||||
input.form-control(name='name', type='name')
|
|
||||||
label Set balance to:
|
|
||||||
input.form-control(name='amount', type='number')
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit',value='Submit')
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
h4 Delete user
|
|
||||||
p This will permanently delete user make sure you get it right
|
|
||||||
form(method='POST', action='/admin/userdelete')
|
|
||||||
#form-group
|
|
||||||
label Username:
|
|
||||||
input.form-control(name='name', type='name')
|
|
||||||
label Confirm Admin Password:
|
|
||||||
input.form-control(name='attempt', type='password')
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit',value='Submit')
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
h4 Change backend URL
|
|
||||||
form(method='POST', action='/admin/changebackend')
|
|
||||||
#form-group
|
|
||||||
p WARNING DO NOT PUT WRONG URL IN YOU WILL BREAK AND HAVE TO DELETE .ENV FILE TO FIX
|
|
||||||
p This will change the backend that is being used by the front end
|
|
||||||
label Enter URL of new BankAPI including trailing slash
|
|
||||||
input.form-control(name='url', type='url')
|
|
||||||
br
|
|
||||||
input.btn.btn-warning(type='submit',value='Submit')
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
h4 Destroy All Sessions
|
|
||||||
form(method='POST', action='/admin/destroyallsessions')
|
|
||||||
#form-group
|
|
||||||
p WARNING THIS WILL DESTROY ALL LOGIN SESSIONS, EVERYONE WILL HAVE TO LOG IN AGAIN
|
|
||||||
label Confirm admin password to DESTROY
|
|
||||||
input.form-control(name='attempt', type='password')
|
|
||||||
br
|
|
||||||
input.btn.btn-danger(type='submit',value='Destroy')
|
|
||||||
br
|
|
||||||
.card.shadow-lg
|
|
||||||
h4 Close Server
|
|
||||||
form(method='POST', action='/admin/close')
|
|
||||||
#form-group
|
|
||||||
p WARNING THIS WILL CLOSE THE SERVER DOWN, IT WILL REQUIRE MANUAL RESTART
|
|
||||||
label Confirm admin password to shutdown
|
|
||||||
input.form-control(name='attempt', type='password')
|
|
||||||
br
|
|
||||||
input.btn.btn-danger(type='submit',value='Shutdown')
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
extends layout
|
|
||||||
|
|
||||||
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
h1 Welcome to the bank interface #{user}
|
|
||||||
.card.shadow-lg
|
|
||||||
.row
|
|
||||||
.col
|
|
||||||
h2 Send Funds
|
|
||||||
.col
|
|
||||||
h4 Balance: #{balance}
|
|
||||||
hr
|
|
||||||
.row
|
|
||||||
.col-4
|
|
||||||
form(method='POST', action='/sendfunds')
|
|
||||||
label Amount to Send:
|
|
||||||
br
|
|
||||||
input.form-control-lg.shadow(type="number" min="0" max=balance name="amount")
|
|
||||||
br
|
|
||||||
br
|
|
||||||
label Reciever:
|
|
||||||
br
|
|
||||||
input.form-control-lg.shadow(name='name', type='text')
|
|
||||||
br
|
|
||||||
br
|
|
||||||
label Your Password:
|
|
||||||
br
|
|
||||||
input.form-control-lg.shadow(name='senderpass', type='password')
|
|
||||||
br
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit', value='Submit')
|
|
||||||
.col-8
|
|
||||||
.card
|
|
||||||
|
|
||||||
ul#transactions.nav.nav-tabs.card-header-tabs(role='tablist')
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link.active.text-black(href='#sent', role='tab', aria-controls='sent', aria-selected='true') Sent
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link.text-black(href='#received', role='tab', aria-controls='recieved', aria-selected='false') Recieved
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link.text-black(href='#balhistory', role='tab', aria-controls='balhistory', aria-selected='false') Balance History
|
|
||||||
.tab-content.mt-3
|
|
||||||
#sent.tab-pane.active(role='tabpanel')
|
|
||||||
.logs
|
|
||||||
if logsent
|
|
||||||
each log in logsent
|
|
||||||
hr
|
|
||||||
p Date: #{log.time}
|
|
||||||
p You sent #{log.to} $#{log.amount}
|
|
||||||
hr
|
|
||||||
#received.tab-pane(role='tabpanel', aria-labelledby='recieved-tab')
|
|
||||||
.logs
|
|
||||||
if logrec
|
|
||||||
each log in logrec
|
|
||||||
hr
|
|
||||||
p Date: #{log.time}
|
|
||||||
p #{log.from} sent you $#{log.amount}
|
|
||||||
hr
|
|
||||||
#balhistory.tab-pane(role='tabpanel', aria-labelledby='balhistory-tab')
|
|
||||||
#chart_div(style="width:100%; height 100%")
|
|
||||||
|
|
||||||
script(type='text/javascript' src='https://www.gstatic.com/charts/loader.js')
|
|
||||||
script(type='text/javascript').
|
|
||||||
|
|
||||||
google.charts.load('current', {'packages':['corechart', 'line']});
|
|
||||||
google.charts.setOnLoadCallback(drawChart);
|
|
||||||
function drawChart() {
|
|
||||||
var data = google.visualization.arrayToDataTable([!{graphdata}]);
|
|
||||||
|
|
||||||
var options = {
|
|
||||||
title: 'Balance',
|
|
||||||
hAxis: {
|
|
||||||
title: 'Transaction',
|
|
||||||
textPosition: 'out',
|
|
||||||
},
|
|
||||||
vAxis: {
|
|
||||||
title: 'Balance',
|
|
||||||
format: 'currency',
|
|
||||||
textPosition: 'out',
|
|
||||||
},
|
|
||||||
trendlines: {
|
|
||||||
0: {type: 'exponential', color: '#333', opacity: .5},
|
|
||||||
1: {type: 'linear', color: '#111', opacity: .3}
|
|
||||||
},
|
|
||||||
width: 670,
|
|
||||||
height: 350,
|
|
||||||
};
|
|
||||||
|
|
||||||
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
|
|
||||||
|
|
||||||
chart.draw(data, options);
|
|
||||||
window.onload = resize;
|
|
||||||
window.onresize = resize;
|
|
||||||
}
|
|
||||||
|
|
||||||
br
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
extends layout
|
|
||||||
|
|
||||||
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
h1 Welcome to CCashBank Front End
|
|
||||||
.card.shadow-lg
|
|
||||||
center
|
|
||||||
h4 Is the server online?
|
|
||||||
if alive
|
|
||||||
h4 YES!
|
|
||||||
if !alive
|
|
||||||
H4 no :(
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
doctype html
|
|
||||||
html
|
|
||||||
head
|
|
||||||
title CCashBank
|
|
||||||
link(rel="stylesheet", href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css", integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z", crossorigin="anonymous")
|
|
||||||
link(rel="preconnect" href="https://fonts.gstatic.com")
|
|
||||||
link(href="https://fonts.googleapis.com/css2?family=Lato&family=Montserrat&display=swap" rel="stylesheet")
|
|
||||||
if random == true
|
|
||||||
link(rel='stylesheet' href='/css/papy.css')
|
|
||||||
if random == false || random == null
|
|
||||||
link(rel='stylesheet' href='/css/style.css')
|
|
||||||
meta(name='viewport', content='width=device-width, initial-scale=1.0')
|
|
||||||
body
|
|
||||||
nav.navbar.navbar-expand-lg.navbar-dark.navbarrr.shadow-lg
|
|
||||||
.container
|
|
||||||
a.navbar-brand(href='/')
|
|
||||||
img(src="/CCashLogo3.png" style="width:75px; height:74px")
|
|
||||||
button.navbar-toggler(type='button', data-toggle='collapse', data-target='#navbars', aria-controls='navbars', aria-expanded='false', aria-label='Toggle navigation')
|
|
||||||
span.navbar-toggler-icon
|
|
||||||
#navbars.collapse.navbar-collapse
|
|
||||||
ul.navbar-nav.mr-auto
|
|
||||||
|
|
||||||
ul.navbar-nav.mr-right.text-white
|
|
||||||
if user == undefined
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link(href='/login').text-white Login
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link(href='/register').text-white Register
|
|
||||||
|
|
||||||
if user
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link(href='/logout').text-white Log out
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link(href='/BankF').text-white Bank
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link(href='/settings').text-white Settings
|
|
||||||
if admin == true
|
|
||||||
li.nav-item
|
|
||||||
a.nav-link(href='/admin').text-white Admin
|
|
||||||
.container
|
|
||||||
!= messages('message', locals)
|
|
||||||
if errors
|
|
||||||
each error, i in errors
|
|
||||||
div(class="alert alert-danger") #{error.msg}
|
|
||||||
if successes
|
|
||||||
each success, i in successes
|
|
||||||
div(class="alert alert-success") #{success.msg}
|
|
||||||
br
|
|
||||||
br
|
|
||||||
block content
|
|
||||||
br
|
|
||||||
hr
|
|
||||||
|
|
||||||
script(src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI="
|
|
||||||
crossorigin="anonymous")
|
|
||||||
script(src='/js/main.js')
|
|
||||||
script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js", integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV", crossorigin="anonymous")
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
extends layout
|
|
||||||
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
.row
|
|
||||||
.col-sm
|
|
||||||
.col
|
|
||||||
.card.shadow-lg
|
|
||||||
h1.text-black Login
|
|
||||||
hr
|
|
||||||
p
|
|
||||||
form(method='POST', action='/login')
|
|
||||||
#form-group
|
|
||||||
label Username:
|
|
||||||
input.form-control(name='name', type='text')
|
|
||||||
br
|
|
||||||
#form-group
|
|
||||||
label Password:
|
|
||||||
input.form-control(name='password', type='password')
|
|
||||||
br
|
|
||||||
|
|
||||||
|
|
||||||
input.btn.btn-primary(type='submit', value='Submit')
|
|
||||||
.col-sm
|
|
||||||
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
extends layout
|
|
||||||
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
h1 Register
|
|
||||||
form(method='POST', action='/register')
|
|
||||||
#form-group
|
|
||||||
label Username:
|
|
||||||
input.form-control(name='name', type='name')
|
|
||||||
label Password:
|
|
||||||
input.form-control(name='password',type='password')
|
|
||||||
label Confirm:
|
|
||||||
input.form-control(name='password2',type='password')
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit',value='Submit')
|
|
||||||
|
|
||||||
br
|
|
||||||
br
|
|
||||||
p Have An Account?
|
|
||||||
a(href="/login").btn.btn-primary Login
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
extends layout
|
|
||||||
|
|
||||||
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
h1 Settings, logged in as: #{user}
|
|
||||||
.card
|
|
||||||
h4 Change password
|
|
||||||
form(method='POST', action='/settings/pass')
|
|
||||||
#form-group
|
|
||||||
label Current Password:
|
|
||||||
input.form-control(name='attempt', type='Password')
|
|
||||||
label New Password:
|
|
||||||
input.form-control(name='new_pass',type='password')
|
|
||||||
label Confirm:
|
|
||||||
input.form-control(name='password2',type='password')
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit',value='Submit')
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
extends layout
|
|
||||||
|
|
||||||
|
|
||||||
block content
|
|
||||||
.container
|
|
||||||
h1 Welcome to CCashBank Front End SETUP
|
|
||||||
.card
|
|
||||||
form(method='POST', action='/setup')
|
|
||||||
#form-group
|
|
||||||
label BANKAPIURL:
|
|
||||||
input.form-control(name='url', type='url')
|
|
||||||
label SSL enabled on front end? leave unchecked if unsure:
|
|
||||||
input.form-control(name='secure', type='checkbox')
|
|
||||||
br
|
|
||||||
input.btn.btn-primary(type='submit',value='Submit')
|
|
||||||
br
|
|
||||||
br
|
|
||||||
11
index.js
11
index.js
|
|
@ -1,3 +1,4 @@
|
||||||
|
const root = process.env.PWD;
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const https = require("https");
|
const https = require("https");
|
||||||
|
|
@ -6,17 +7,16 @@ const bodyParser = require("body-parser");
|
||||||
const expressValidator = require("express-validator");
|
const expressValidator = require("express-validator");
|
||||||
const flash = require("connect-flash");
|
const flash = require("connect-flash");
|
||||||
const session = require("express-session");
|
const session = require("express-session");
|
||||||
const { ensureAuthenticated } = require("./config/auth.js");
|
const { ensureAuthenticated } = require(`${root}/config/auth.js`);
|
||||||
const app = express();
|
const app = express();
|
||||||
const MemoryStore = require("memorystore")(session);
|
const MemoryStore = require("memorystore")(session);
|
||||||
const url = require("url");
|
const url = require("url");
|
||||||
const dotenv = require("dotenv");
|
const dotenv = require("dotenv");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
let Log = require("./schemas/log.js");
|
|
||||||
const mongoose = require("mongoose");
|
const mongoose = require("mongoose");
|
||||||
const { CCashClient } = require("ccash-client-js");
|
const { CCashClient } = require("ccash-client-js");
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const { postUser } = require("./helpers/functions.js");
|
const { postUser } = require(`${root}/helpers/functions.js`);
|
||||||
|
|
||||||
app.set("views", path.join(__dirname, "views"));
|
app.set("views", path.join(__dirname, "views"));
|
||||||
app.set("view engine", "pug");
|
app.set("view engine", "pug");
|
||||||
|
|
@ -34,6 +34,7 @@ app.use(function (req, res, next) {
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
app.set("trust proxy", 1); // trust first proxy
|
app.set("trust proxy", 1); // trust first proxy
|
||||||
|
const secure = process.env.SECURE;
|
||||||
app.use(
|
app.use(
|
||||||
session({
|
session({
|
||||||
secret: "fuck shit cunt",
|
secret: "fuck shit cunt",
|
||||||
|
|
@ -42,7 +43,7 @@ app.use(
|
||||||
checkPeriod: 86400000, // prune expired entries every 24h
|
checkPeriod: 86400000, // prune expired entries every 24h
|
||||||
}),
|
}),
|
||||||
saveUninitialized: true,
|
saveUninitialized: true,
|
||||||
cookie: { secure: process.env.SECURE, maxAge: 86400000 },
|
cookie: { secure: secure, maxAge: 86400000 },
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
app.use(
|
app.use(
|
||||||
|
|
@ -245,7 +246,7 @@ app.post("/register", async function (req, res) {
|
||||||
req.session.successes = [];
|
req.session.successes = [];
|
||||||
if (!name || !password || !password2) {
|
if (!name || !password || !password2) {
|
||||||
req.session.errors.push({ msg: "please fill in all fields" });
|
req.session.errors.push({ msg: "please fill in all fields" });
|
||||||
} else if (password !== password2) {
|
} else if (password != password2) {
|
||||||
req.session.errors.push({ msg: "Passwords don't match" });
|
req.session.errors.push({ msg: "Passwords don't match" });
|
||||||
} else if (password.length < 6) {
|
} else if (password.length < 6) {
|
||||||
req.session.errors.push({
|
req.session.errors.push({
|
||||||
|
|
|
||||||
12
pm2.json
12
pm2.json
|
|
@ -1,12 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ccashfrontend",
|
"name": "ccashfrontend",
|
||||||
"script": "index.js",
|
"script": "/app/ccashfrontend/index.js",
|
||||||
"watch": "tmp/restart.txt",
|
"watch": "/app/ccashfrontend/tmp/restart.txt",
|
||||||
"instances": "1",
|
"instances": "1"
|
||||||
"env": {
|
|
||||||
"NODE_ENV": "development"
|
|
||||||
},
|
|
||||||
"env_production": {
|
|
||||||
"NODE_ENV": "production"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
|
const root = process.env.PWD;
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { ensureAuthenticated } = require("../config/auth.js");
|
const { ensureAuthenticated } = require(`${root}/config/auth.js`);
|
||||||
const { checkAdmin } = require("../config/admin.js");
|
const { checkAdmin } = require(`${root}/config/admin.js`);
|
||||||
const pug = require("pug");
|
const pug = require("pug");
|
||||||
const flash = require("connect-flash");
|
const flash = require("connect-flash");
|
||||||
const expressValidator = require("express-validator");
|
const expressValidator = require("express-validator");
|
||||||
const session = require("express-session");
|
const session = require("express-session");
|
||||||
const { postUser } = require("../helpers/functions.js");
|
const { postUser } = require(`${root}/helpers/functions.js`);
|
||||||
const got = require("got");
|
const got = require("got");
|
||||||
const MemoryStore = require("memorystore")(session);
|
const MemoryStore = require("memorystore")(session);
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
@ -146,7 +147,7 @@ router.post("/changebackend", checkAdmin, async function (req, res) {
|
||||||
}
|
}
|
||||||
process.env.BANKAPIURL = url;
|
process.env.BANKAPIURL = url;
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
".env",
|
`${root}/.env`,
|
||||||
"BANKAPIURL=" +
|
"BANKAPIURL=" +
|
||||||
process.env.BANKAPIURL +
|
process.env.BANKAPIURL +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
|
@ -160,8 +161,8 @@ router.post("/changebackend", checkAdmin, async function (req, res) {
|
||||||
process.env.MONGO +
|
process.env.MONGO +
|
||||||
"\nSETUP=true"
|
"\nSETUP=true"
|
||||||
);
|
);
|
||||||
fs.mkdirSync("tmp");
|
fs.mkdirSync(`${root}/tmp`);
|
||||||
fs.writeFileSync("tmp/restart.txt", "");
|
fs.writeFileSync(`${root}tmp/restart.txt`, "");
|
||||||
res.redirect("../");
|
res.redirect("../");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
|
const root = process.env.PWD;
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { ensureAuthenticated } = require("../config/auth.js");
|
const { ensureAuthenticated } = require(`${root}/config/auth.js`);
|
||||||
const { checkAdmin } = require("../config/admin.js");
|
const { checkAdmin } = require(`${root}/config/admin.js`);
|
||||||
var pug = require("pug");
|
var pug = require("pug");
|
||||||
const flash = require("connect-flash");
|
const flash = require("connect-flash");
|
||||||
const expressValidator = require("express-validator");
|
const expressValidator = require("express-validator");
|
||||||
const session = require("express-session");
|
const session = require("express-session");
|
||||||
const { postUser } = require("../helpers/functions.js");
|
const { postUser } = require(`${root}/helpers/functions.js`);
|
||||||
const { CCashClient } = require("ccash-client-js");
|
const { CCashClient } = require("ccash-client-js");
|
||||||
|
|
||||||
router.get("/", ensureAuthenticated, function (req, res) {
|
router.get("/", ensureAuthenticated, function (req, res) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,5 @@ block content
|
||||||
h4 Is the server online?
|
h4 Is the server online?
|
||||||
if alive
|
if alive
|
||||||
h4 YES!
|
h4 YES!
|
||||||
h4 #{url}
|
|
||||||
if !alive
|
if !alive
|
||||||
H4 no :(
|
H4 no :(
|
||||||
h4 #{url}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue