2nd fix for multi tenancy groups

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

View File

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

View File

@ -7,6 +7,17 @@ const extractAppId = id => {
return split.length ? split[split.length - 1] : null 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() { export function createAppStore() {
const store = writable([]) const store = writable([])
@ -79,6 +90,7 @@ export function createAppStore() {
load, load,
update, update,
extractAppId, extractAppId,
getProdAppID,
} }
} }

View File

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