Update 'index.js'

This commit is contained in:
asyncnomi 2022-12-11 15:08:47 +00:00
parent e9b5dca6ec
commit 0ccf0d4b0f

View file

@ -3,6 +3,11 @@ const fs = require('fs');
const path = require('path')
var LdapAuth = require('ldapauth-fork');
var prankPath = "prankdata.txt";
if (!fs.existsSync(prankPath)) {
fs.writeFileSync(prankPath, "{}");
}
let PrankData = JSON.parse(fs.readFileSync("prankdata.txt"));
let AdminUsersUid = ["asyncnomi", "johan", "enthalpine", "fas", "arina", "billy", "remi", "pierre", "", "", "", ""];
let UsersToken = {};
@ -241,7 +246,7 @@ fastify.post('/getPrank', async (request, reply) => {
function saveData() {
fs.writeFileSync('prankdata.txt', JSON.stringify(PrankData));
fs.writeFileSync(prankPath, JSON.stringify(PrankData));
}
function authenticate(user, pwd) {
@ -342,7 +347,7 @@ function makeid(length) {
const start = async () => {
try {
await fastify.listen({ port: 3000 })
await fastify.listen({ port: 80 })
} catch (err) {
fastify.log.error(err)
LDAP.close(function(err) {