Added massive logs

This commit is contained in:
Thomas Forgione 2019-03-28 14:12:38 +01:00
parent 9d40a529df
commit cf3d7d2661
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 15 additions and 0 deletions

View File

@ -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) => {