Updated all routes (#12)

This commit is contained in:
2023-01-19 10:41:12 -05:00
committed by GitHub
parent eabb8199dc
commit ec9092abf3
6 changed files with 105 additions and 99 deletions

View File

@@ -15,7 +15,7 @@ let User = require('../schema/user.model');
*/
adminRoutes.route('/stats').post((req, res) => {
if (!req.body) {
res.status(401).send("Missing body");
res.status(401).json({ success: false, response: "Missing body" });
return;
}
utils.account.checkSession(req.body.userId, req.body.sessionId, (isValidId) => {
@@ -31,13 +31,13 @@ adminRoutes.route('/stats').post((req, res) => {
User.count({}, (err, userCount) => {
stats.userCount = userCount;
stats.date = Date();
res.json(stats);
res.status(200).json({ success: true, response: stats });
});
});
});
});
} else {
res.status(401).send("Invalid permissions to view stats.");
res.status(401).json({ success: false, response: "Invalid permissions to view stats" });
return;
}
})