Merge pull request #6159 from Budibase/fix/users-list

fix users list on app overview
This commit is contained in:
Martin McKeaveney 2022-06-01 15:41:43 +01:00 committed by GitHub
commit e751b45859
2 changed files with 12 additions and 1 deletions

View File

@ -6,6 +6,7 @@ const Joi = require("joi")
const cloudRestricted = require("../../../middleware/cloudRestricted")
const { buildUserSaveValidation } = require("../../utilities/validation")
const selfController = require("../../controllers/global/self")
const builderOrAdmin = require("../../../middleware/builderOrAdmin")
const router = Router()
@ -44,7 +45,7 @@ router
buildUserSaveValidation(),
controller.save
)
.get("/api/global/users", adminOnly, controller.fetch)
.get("/api/global/users", builderOrAdmin, controller.fetch)
.delete("/api/global/users/:id", adminOnly, controller.destroy)
.get("/api/global/roles/:appId")
.post(

View File

@ -0,0 +1,10 @@
module.exports = async (ctx, next) => {
if (
!ctx.internal &&
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global) &&
(!ctx.user || !ctx.user.admin || !ctx.user.admin.global)
) {
ctx.throw(403, "Builder user only endpoint.")
}
return next()
}