2nd fix for multi tenancy groups

This commit is contained in:
Peter Clement 2022-07-22 10:56:16 +01:00
parent 723bbd65e4
commit dd34282a33
3 changed files with 14 additions and 10 deletions

View File

@ -35,13 +35,8 @@
Constants.Features.USER_GROUPS
)
$: {
if (!app.tenantId) {
fixedAppId = `app_${app.appId}`
} else {
fixedAppId = `app_${app.tenantId}_${app.appId}`
}
}
$: fixedAppId = apps.getProdAppID(app.devId)
$: appUsers =
$users.data?.filter(x => {
return Object.keys(x.roles).find(y => {

View File

@ -7,6 +7,17 @@ const extractAppId = id => {
return split.length ? split[split.length - 1] : null
}
const getProdAppID = appId => {
if (!appId || !appId.startsWith("app_dev")) {
return appId
}
// split to take off the app_dev element, then join it together incase any other app_ exist
const split = appId.split("app_dev")
split.shift()
const rest = split.join("app_dev")
return `${"app"}${rest}`
}
export function createAppStore() {
const store = writable([])
@ -79,6 +90,7 @@ export function createAppStore() {
load,
update,
extractAppId,
getProdAppID,
}
}

View File

@ -15,7 +15,6 @@ const { getAppId } = require("@budibase/backend-core/context")
const { groups } = require("@budibase/pro")
exports.updateAppRole = async (user, { appId } = {}) => {
console.log(appId)
appId = appId || getAppId()
if (!user || !user.roles) {
return user
@ -38,8 +37,6 @@ exports.updateAppRole = async (user, { appId } = {}) => {
let roleId = await groups.getGroupRoleId(user, appId)
user.roleId = roleId
}
console.log(user.roleId)
delete user.roles
return user
}