backend send details on error
This commit is contained in:
@@ -72,7 +72,7 @@ app.use(passport.session());
|
|||||||
|
|
||||||
app.get("*", function (req, res, next) {
|
app.get("*", function (req, res, next) {
|
||||||
if (!serverStartupComplete)
|
if (!serverStartupComplete)
|
||||||
return res.send("Server is starting...");
|
return res.send("Server is starting... Please try again soon.");
|
||||||
else return next();
|
else return next();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ passport.use('local-login', new LocalStrategy({
|
|||||||
email = mysql.escape(email);
|
email = mysql.escape(email);
|
||||||
connection.query(`SELECT * from user WHERE email = ${email} AND deactivated = 0`, function (err, rows) {
|
connection.query(`SELECT * from user WHERE email = ${email} AND deactivated = 0`, function (err, rows) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.status(static.INTERNAL_SERVER_ERROR).send();
|
return res.status(static.INTERNAL_SERVER_ERROR).send("error querying the database - Please contact sys admin");
|
||||||
}
|
}
|
||||||
if (!rows.length) {
|
if (!rows.length) {
|
||||||
return done(null, false);
|
return done(null, false);
|
||||||
@@ -120,7 +120,7 @@ passport.deserializeUser(function (id, done) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post("/API/user/login", passport.authenticate('local-login'), function (req, res) {
|
app.post("/API/user/login", passport.authenticate('local-login'), function (req, res) {
|
||||||
res.status(status.OK).send();
|
res.status(status.OK).send("login success");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.put("/API/user/create", function (req, res) {
|
app.put("/API/user/create", function (req, res) {
|
||||||
@@ -130,11 +130,11 @@ app.put("/API/user/create", function (req, res) {
|
|||||||
password = mysql.escape(bcrypt.hashSync(password, saltRounds));
|
password = mysql.escape(bcrypt.hashSync(password, saltRounds));
|
||||||
connection.query(`INSERT INTO user (deactivated, email, password) values (1, ${email}, ${password})`, function (err, rows) {
|
connection.query(`INSERT INTO user (deactivated, email, password) values (1, ${email}, ${password})`, function (err, rows) {
|
||||||
if (err)
|
if (err)
|
||||||
return res.send(status.INTERNAL_SERVER_ERROR).send();
|
return res.send(status.INTERNAL_SERVER_ERROR).send("the user seems to exist already - if you think this is an error contact the sys admin");
|
||||||
return res.status(status.OK).send();
|
return res.status(status.OK).send();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.status(status.BAD_REQUEST).send();
|
res.status(status.BAD_REQUEST).send("invalid data supplied");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ app.all("*", function (req, res, next) {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.status(status.UNAUTHORIZED).send();
|
res.status(status.UNAUTHORIZED).send("please log in before using this site");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ app.get('/API/day', function (req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res.status(status.BAD_REQUEST).send("invalid data provided");
|
res.status(status.BAD_REQUEST).send("invalid data range provided");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user