From cf3d7d2661fccc07f05010fc8bdb3401322e095a Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Thu, 28 Mar 2019 14:12:38 +0100 Subject: [PATCH] Added massive logs --- server.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server.js b/server.js index 0e041ee..7a0827b 100644 --- a/server.js +++ b/server.js @@ -150,12 +150,15 @@ function readData(req, res, callback) { function saveArchiveAndRun(req, res) { + console.log("Saving archive"); + let path = pathtools.join(aisPath, req.body.name); try { fs.mkdirSync(path); } catch { } let zipfile = pathtools.join(path, 'archive.zip'); req.files.archive.mv(zipfile, (err) => { if (err != null) { + console.log("Failed to save archive"); console.log(err); res.render('error', {message: 'Unable to save the ZIP archive to the server'}); return; @@ -222,6 +225,8 @@ function startServer() { app.post('/upload-target', (req, res) => { + console.log("/upload-target"); + if (!req.body.name) { res.render('error', {message: "You have to enter a name in the form"}); return; @@ -252,6 +257,9 @@ function startServer() { if (aiExisted) { + + console.log("Ai existed, try to verify password"); + fs.readFile(pathtools.join(path, hashPath), 'utf-8', function(err, data) { if (err != null) { @@ -268,10 +276,13 @@ function startServer() { } if (!success) { + console.log("Authentication failed"); res.render('error', {message: "Authentication failed"}); return; } + console.log("Authentication complete"); + try { if (fs.statSync(path).isDirectory()) { // Move it to old @@ -300,6 +311,8 @@ function startServer() { }); }); } else { + + console.log("New user, hashing password"); bcrypt.hash(req.body.password, 10, function(err, hash) { if (err != null) { @@ -307,6 +320,8 @@ function startServer() { return; } + console.log("Storing password"); + // Store hash in your password DB. fs.writeFile(pathtools.join(path, hashPath), hash, (err) => {