Merge branch 'user-app-list' of github.com:Budibase/budibase into user-app-list

This commit is contained in:
Andrew Kingston 2021-05-19 13:38:21 +01:00
commit 4824d7810a
3 changed files with 12 additions and 3 deletions

View File

@ -48,7 +48,7 @@ exports.updateMetadata = async function (ctx) {
const appId = ctx.appId
const db = new CouchDB(appId)
const user = ctx.request.body
// make sure to always remove global user props
// make sure to always remove some of the global user props
delete user.password
delete user.roles
delete user.builder

View File

@ -96,7 +96,15 @@ exports.destroy = async ctx => {
}
}
exports.self = async ctx => {
exports.getSelf = async ctx => {
ctx.params = {
id: ctx.user._id
}
// this will set the body
await exports.find(ctx)
}
exports.updateSelf = async ctx => {
const db = new CouchDB(GLOBAL_DB)
const user = await db.get(ctx.user._id)
if (ctx.request.body.password) {

View File

@ -60,7 +60,8 @@ router
.post("/api/admin/users", buildUserSaveValidation(), controller.save)
.get("/api/admin/users", controller.fetch)
.post("/api/admin/users/init", controller.adminUser)
.post("/api/admin/users/self", buildUserSaveValidation(true), controller.self)
.get("/api/admin/users/self", controller.getSelf)
.post("/api/admin/users/self", buildUserSaveValidation(true), controller.updateSelf)
.delete("/api/admin/users/:id", controller.destroy)
.get("/api/admin/users/:id", controller.find)
.get("/api/admin/roles/:appId")