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) {
|
||||
|
||||
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) => {
|
||||
|
||||
|
|
Loading…
Reference in New Issue