add get user/group,

invert  return value for CookieFetcher
This commit is contained in:
2024-08-02 04:35:04 +00:00
parent 783bc37c94
commit c059b528fa
4 changed files with 57 additions and 11 deletions
+25 -3
View File
@@ -6,8 +6,8 @@ const checkAuth = global.utils.checkAuth;
/**
* GET - get all groups
* responses:
* - 200: {auth:true, groups: Array}
* - 201: {auth: false}
* - 200: {auth: true, groups: Array}
* - 401: {auth: false}
*/
router.get("/", async (req, res) => {
// check auth
@@ -15,5 +15,27 @@ router.get("/", async (req, res) => {
if (!auth) {
return;
}
res.status(200).send(global.userManager.getAllGroups());
const groups = await global.userManager.getAllGroups(req.cookies);
res.status(200).send({ groups });
});
/**
* GET - get specific group
* request:
* - groupname: name of group to get
* responses:
* - 200: {auth: true, group: Object}
* - 401: {auth: false}
*/
router.get("/:groupname", async (req, res) => {
const params = {
groupname: req.params.groupname
};
// check auth
const auth = await checkAuth(req.cookies, res);
if (!auth) {
return;
}
const group = await global.userManager.getGroup(params.groupname, req.cookies);
res.status(200).send({ group });
});