Merge branch 'user-app-list' of github.com:Budibase/budibase into user-app-list
This commit is contained in:
commit
4824d7810a
|
@ -48,7 +48,7 @@ exports.updateMetadata = async function (ctx) {
|
||||||
const appId = ctx.appId
|
const appId = ctx.appId
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
const user = ctx.request.body
|
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.password
|
||||||
delete user.roles
|
delete user.roles
|
||||||
delete user.builder
|
delete user.builder
|
||||||
|
|
|
@ -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 db = new CouchDB(GLOBAL_DB)
|
||||||
const user = await db.get(ctx.user._id)
|
const user = await db.get(ctx.user._id)
|
||||||
if (ctx.request.body.password) {
|
if (ctx.request.body.password) {
|
||||||
|
|
|
@ -60,7 +60,8 @@ router
|
||||||
.post("/api/admin/users", buildUserSaveValidation(), controller.save)
|
.post("/api/admin/users", buildUserSaveValidation(), controller.save)
|
||||||
.get("/api/admin/users", controller.fetch)
|
.get("/api/admin/users", controller.fetch)
|
||||||
.post("/api/admin/users/init", controller.adminUser)
|
.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)
|
.delete("/api/admin/users/:id", controller.destroy)
|
||||||
.get("/api/admin/users/:id", controller.find)
|
.get("/api/admin/users/:id", controller.find)
|
||||||
.get("/api/admin/roles/:appId")
|
.get("/api/admin/roles/:appId")
|
||||||
|
|
Loading…
Reference in New Issue