add get user/group,
invert return value for CookieFetcher
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user