better graphs - group modal fix - system list

This commit is contained in:
Luke Berndt
2023-04-24 20:37:07 -04:00
parent 7b56dc70a6
commit 8c9e74e008
16 changed files with 1005 additions and 13 deletions

View File

@@ -79,7 +79,7 @@ function isOwner(req, res, next) {
}
}
/*
function isAdmin(req, res, next) {
if (req.params.shortName && req.user) {
var short_name = req.params.shortName.toLowerCase();
@@ -99,7 +99,7 @@ function isAdmin(req, res, next) {
}
});
}
}
}*/
function isLoggedIn(req, res, next) {
if (req.isAuthenticated()) return next();
@@ -109,6 +109,16 @@ function isLoggedIn(req, res, next) {
});
};
function isAdmin(req, res, next) {
if (req.isAuthenticated() && req.user.admin) return next();
res.status(401).send({
success: false,
message: "Not Authenticated."
});
};
function uploadFile(req, res, next) {
const upload = multer({dest: 'uploads/'}).single('file');
@@ -142,6 +152,7 @@ app.post("/groups/:shortName/:groupId?", isLoggedIn, groups.upsertGroup);
app.get("/groups/:shortName/:groupId?", isLoggedIn, groups.getGroups);
app.delete("/groups/:shortName/:groupId", isLoggedIn, groups.deleteGroup);
app.get("/systems", isLoggedIn, systems.listSystems)
app.get("/admin/systems", isAdmin, systems.listAllSystems)
app.delete("/systems/:shortName", isLoggedIn, systems.deleteSystem)
app.post("/systems/:shortName", [isLoggedIn, systems.ownSystem, systems.validateSystem, systems.updateSystem])
app.post("/systems", [isLoggedIn, systems.uniqueShortName, systems.validateSystem, systems.createSystem])