add get all users/groups routes
This commit is contained in:
parent
7f48f49445
commit
800033c6f8
@ -76,6 +76,13 @@ class USER_BACKEND extends BACKEND {
|
|||||||
*/
|
*/
|
||||||
getUser (user, params = null) {}
|
getUser (user, params = null) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all users from backend
|
||||||
|
* @param {Object} params authentication params, usually req.cookies
|
||||||
|
* @returns {Array} containing each user data from this backend
|
||||||
|
*/
|
||||||
|
getAllUsers (params = null) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify user in backend
|
* Modify user in backend
|
||||||
* @param {{id: string, realm: string}} user
|
* @param {{id: string, realm: string}} user
|
||||||
@ -110,6 +117,13 @@ class USER_BACKEND extends BACKEND {
|
|||||||
*/
|
*/
|
||||||
getGroup (group, params = null) {}
|
getGroup (group, params = null) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all users from backend
|
||||||
|
* @param {Object} params authentication params, usually req.cookies
|
||||||
|
* @returns {Array} containing each group data from this backend
|
||||||
|
*/
|
||||||
|
getAllGroups (params = null) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify group in backend
|
* Modify group in backend
|
||||||
* @param {{id: string}} group
|
* @param {{id: string}} group
|
||||||
@ -190,6 +204,8 @@ class USER_BACKEND_MANAGER extends USER_BACKEND {
|
|||||||
return userData;
|
return userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAllUsers (params = null) {}
|
||||||
|
|
||||||
async setUser (user, attributes, params = null) {
|
async setUser (user, attributes, params = null) {
|
||||||
const results = {
|
const results = {
|
||||||
ok: true,
|
ok: true,
|
||||||
@ -213,6 +229,8 @@ class USER_BACKEND_MANAGER extends USER_BACKEND {
|
|||||||
|
|
||||||
getGroup (group, params = null) {}
|
getGroup (group, params = null) {}
|
||||||
|
|
||||||
|
getAllGroups (params = null) {}
|
||||||
|
|
||||||
setGroup (group, attributes, params = null) {}
|
setGroup (group, attributes, params = null) {}
|
||||||
|
|
||||||
delGroup (group, params = null) {}
|
delGroup (group, params = null) {}
|
||||||
|
@ -3,6 +3,8 @@ export const router = Router({ mergeParams: true }); ;
|
|||||||
|
|
||||||
const checkAuth = global.utils.checkAuth;
|
const checkAuth = global.utils.checkAuth;
|
||||||
|
|
||||||
|
global.utils.recursiveImportRoutes(router, "/access", "access", import.meta.url);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET - check authentication
|
* GET - check authentication
|
||||||
* responses:
|
* responses:
|
||||||
|
16
src/routes/access/groups.js
Normal file
16
src/routes/access/groups.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
export const router = Router({ mergeParams: true });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET - get all groups
|
||||||
|
* responses:
|
||||||
|
* - 200: {auth:true, groups: Array}
|
||||||
|
* - 201: {auth: false}
|
||||||
|
*/
|
||||||
|
router.get("/", async (req, res) => {
|
||||||
|
const auth = await checkAuth(req.cookies, res);
|
||||||
|
if (!auth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.status(200).send(global.userManager.getAllGroups())
|
||||||
|
});
|
16
src/routes/access/users.js
Normal file
16
src/routes/access/users.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
export const router = Router({ mergeParams: true });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET - get all users
|
||||||
|
* responses:
|
||||||
|
* - 200: {auth:true, users: Array}
|
||||||
|
* - 201: {auth: false}
|
||||||
|
*/
|
||||||
|
router.get("/", async (req, res) => {
|
||||||
|
const auth = await checkAuth(req.cookies, res);
|
||||||
|
if (!auth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.status(200).send(global.userManager.getAllUsers())
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user