Allow developers to manage user access

This commit is contained in:
Mel O'Hagan 2022-11-28 16:01:27 +00:00
parent 28cc20e938
commit bc68b16526
1 changed files with 5 additions and 6 deletions

View File

@ -1,7 +1,6 @@
const Router = require("@koa/router") const Router = require("@koa/router")
const controller = require("../../controllers/global/users") const controller = require("../../controllers/global/users")
const { joiValidator } = require("@budibase/backend-core/auth") const { joiValidator } = require("@budibase/backend-core/auth")
const { adminOnly } = require("@budibase/backend-core/auth")
const Joi = require("joi") const Joi = require("joi")
const cloudRestricted = require("../../../middleware/cloudRestricted") const cloudRestricted = require("../../../middleware/cloudRestricted")
const { users } = require("../validation") const { users } = require("../validation")
@ -51,31 +50,31 @@ function buildInviteAcceptValidation() {
router router
.post( .post(
"/api/global/users", "/api/global/users",
adminOnly, builderOrAdmin,
users.buildUserSaveValidation(), users.buildUserSaveValidation(),
controller.save controller.save
) )
.post( .post(
"/api/global/users/bulk", "/api/global/users/bulk",
adminOnly, builderOrAdmin,
users.buildUserBulkUserValidation(), users.buildUserBulkUserValidation(),
controller.bulkUpdate controller.bulkUpdate
) )
.get("/api/global/users", builderOrAdmin, controller.fetch) .get("/api/global/users", builderOrAdmin, controller.fetch)
.post("/api/global/users/search", builderOrAdmin, controller.search) .post("/api/global/users/search", builderOrAdmin, controller.search)
.delete("/api/global/users/:id", adminOnly, controller.destroy) .delete("/api/global/users/:id", builderOrAdmin, controller.destroy)
.get("/api/global/users/count/:appId", builderOrAdmin, controller.countByApp) .get("/api/global/users/count/:appId", builderOrAdmin, controller.countByApp)
.get("/api/global/roles/:appId") .get("/api/global/roles/:appId")
.post( .post(
"/api/global/users/invite", "/api/global/users/invite",
adminOnly, builderOrAdmin,
buildInviteValidation(), buildInviteValidation(),
controller.invite controller.invite
) )
.post( .post(
"/api/global/users/multi/invite", "/api/global/users/multi/invite",
adminOnly, builderOrAdmin,
buildInviteMultipleValidation(), buildInviteMultipleValidation(),
controller.inviteMultiple controller.inviteMultiple
) )