Added massive logs
This commit is contained in:
parent
9d40a529df
commit
cf3d7d2661
15
server.js
15
server.js
|
@ -150,12 +150,15 @@ function readData(req, res, callback) {
|
||||||
|
|
||||||
function saveArchiveAndRun(req, res) {
|
function saveArchiveAndRun(req, res) {
|
||||||
|
|
||||||
|
console.log("Saving archive");
|
||||||
|
|
||||||
let path = pathtools.join(aisPath, req.body.name);
|
let path = pathtools.join(aisPath, req.body.name);
|
||||||
try { fs.mkdirSync(path); } catch { }
|
try { fs.mkdirSync(path); } catch { }
|
||||||
|
|
||||||
let zipfile = pathtools.join(path, 'archive.zip');
|
let zipfile = pathtools.join(path, 'archive.zip');
|
||||||
req.files.archive.mv(zipfile, (err) => {
|
req.files.archive.mv(zipfile, (err) => {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
|
console.log("Failed to save archive");
|
||||||
console.log(err);
|
console.log(err);
|
||||||
res.render('error', {message: 'Unable to save the ZIP archive to the server'});
|
res.render('error', {message: 'Unable to save the ZIP archive to the server'});
|
||||||
return;
|
return;
|
||||||
|
@ -222,6 +225,8 @@ function startServer() {
|
||||||
|
|
||||||
app.post('/upload-target', (req, res) => {
|
app.post('/upload-target', (req, res) => {
|
||||||
|
|
||||||
|
console.log("/upload-target");
|
||||||
|
|
||||||
if (!req.body.name) {
|
if (!req.body.name) {
|
||||||
res.render('error', {message: "You have to enter a name in the form"});
|
res.render('error', {message: "You have to enter a name in the form"});
|
||||||
return;
|
return;
|
||||||
|
@ -252,6 +257,9 @@ function startServer() {
|
||||||
|
|
||||||
|
|
||||||
if (aiExisted) {
|
if (aiExisted) {
|
||||||
|
|
||||||
|
console.log("Ai existed, try to verify password");
|
||||||
|
|
||||||
fs.readFile(pathtools.join(path, hashPath), 'utf-8', function(err, data) {
|
fs.readFile(pathtools.join(path, hashPath), 'utf-8', function(err, data) {
|
||||||
|
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
|
@ -268,10 +276,13 @@ function startServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
console.log("Authentication failed");
|
||||||
res.render('error', {message: "Authentication failed"});
|
res.render('error', {message: "Authentication failed"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Authentication complete");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (fs.statSync(path).isDirectory()) {
|
if (fs.statSync(path).isDirectory()) {
|
||||||
// Move it to old
|
// Move it to old
|
||||||
|
@ -300,6 +311,8 @@ function startServer() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
console.log("New user, hashing password");
|
||||||
bcrypt.hash(req.body.password, 10, function(err, hash) {
|
bcrypt.hash(req.body.password, 10, function(err, hash) {
|
||||||
|
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
|
@ -307,6 +320,8 @@ function startServer() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Storing password");
|
||||||
|
|
||||||
// Store hash in your password DB.
|
// Store hash in your password DB.
|
||||||
fs.writeFile(pathtools.join(path, hashPath), hash, (err) => {
|
fs.writeFile(pathtools.join(path, hashPath), hash, (err) => {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue