various code cleanup and commenting

This commit is contained in:
2026-05-26 22:35:56 +00:00
parent 46295fabde
commit af2194a8b3
14 changed files with 229 additions and 123 deletions
+9 -5
View File
@@ -1,8 +1,6 @@
import { Router } from "express";
export const router = Router({ mergeParams: true });
const checkAuth = global.utils.checkAuth;
/**
* GET - get specific group
* request:
@@ -16,18 +14,24 @@ router.get("/:groupname", async (req, res) => {
groupname: req.params.groupname
};
// check auth
const auth = await checkAuth(req.cookies, res);
const auth = await global.utils.checkAuth(req.cookies, res);
if (!auth) {
return;
}
// attempt to parse group from groupname
const groupObj = global.utils.getGroupObjFromGroupname(params.groupname);
if (groupObj == null) {
res.status(400).send({ auth: true, error:`Groupname ${params.groupname} does not match format gid-realm or gid.` });
}
// get group
const g = await global.access.getGroup(groupObj, req.cookies);
if (g.ok !== true) {
res.status(g.status).send(g);
res.status(g.status).send({ auth:true, error:g });
return;
}
const group = g.group;
res.status(200).send({ group });
res.status(200).send({ auth:true, group });
});