Fixing two issues which were blocking previews, one the user was no longer being updated as an admin (when first building/creating an app) and two, role was not being carried across from global user properly.
This commit is contained in:
parent
ecde960fd9
commit
4652aaa16f
|
@ -5,7 +5,7 @@ const {
|
|||
getGlobalIDFromUserMetadataID,
|
||||
} = require("../../db/utils")
|
||||
const { InternalTables } = require("../../db/utils")
|
||||
const { getRole } = require("../../utilities/security/roles")
|
||||
const { getRole, BUILTIN_ROLE_IDS } = require("../../utilities/security/roles")
|
||||
const {
|
||||
getGlobalUsers,
|
||||
saveGlobalUser,
|
||||
|
@ -73,6 +73,9 @@ exports.createMetadata = async function (ctx) {
|
|||
exports.updateSelfMetadata = async function (ctx) {
|
||||
// overwrite the ID with current users
|
||||
ctx.request.body._id = ctx.user._id
|
||||
if (ctx.user.builder && ctx.user.builder.global) {
|
||||
ctx.request.body.roleId = BUILTIN_ROLE_IDS.ADMIN
|
||||
}
|
||||
// make sure no stale rev
|
||||
delete ctx.request.body._rev
|
||||
await exports.updateMetadata(ctx)
|
||||
|
|
|
@ -31,9 +31,8 @@ module.exports = async (ctx, next) => {
|
|||
const globalUser = await getGlobalUsers(ctx, requestAppId, ctx.user._id)
|
||||
updateCookie = true
|
||||
appId = requestAppId
|
||||
if (globalUser.roles && globalUser.roles[requestAppId]) {
|
||||
roleId = globalUser.roles[requestAppId]
|
||||
}
|
||||
// retrieving global user gets the right role
|
||||
roleId = globalUser.roleId
|
||||
} else if (appCookie != null) {
|
||||
appId = appCookie.appId
|
||||
roleId = appCookie.roleId || BUILTIN_ROLE_IDS.PUBLIC
|
||||
|
|
Loading…
Reference in New Issue