Merge pull request #1711 from Budibase/fix/1710
Quick fix for issue #1710
This commit is contained in:
commit
870088d5e3
|
@ -104,6 +104,7 @@
|
||||||
options={$roles}
|
options={$roles}
|
||||||
getOptionLabel={role => role.name}
|
getOptionLabel={role => role.name}
|
||||||
getOptionValue={role => role._id}
|
getOptionValue={role => role._id}
|
||||||
|
disabled={!creating}
|
||||||
/>
|
/>
|
||||||
{#each customSchemaKeys as [key, meta]}
|
{#each customSchemaKeys as [key, meta]}
|
||||||
{#if !meta.autocolumn}
|
{#if !meta.autocolumn}
|
||||||
|
|
|
@ -33,12 +33,16 @@
|
||||||
role: {},
|
role: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: defaultRoleId = $userFetch?.data?.builder?.global ? "ADMIN" : ""
|
||||||
// Merge the Apps list and the roles response to get something that makes sense for the table
|
// Merge the Apps list and the roles response to get something that makes sense for the table
|
||||||
$: appList = Object.keys($apps?.data).map(id => ({
|
$: appList = Object.keys($apps?.data).map(id => {
|
||||||
|
const role = $userFetch?.data?.roles?.[id] || defaultRoleId
|
||||||
|
return {
|
||||||
...$apps?.data?.[id],
|
...$apps?.data?.[id],
|
||||||
_id: id,
|
_id: id,
|
||||||
role: [$userFetch?.data?.roles?.[id]],
|
role: [role],
|
||||||
}))
|
}
|
||||||
|
})
|
||||||
let selectedApp
|
let selectedApp
|
||||||
|
|
||||||
const userFetch = fetchData(`/api/admin/users/${userId}`)
|
const userFetch = fetchData(`/api/admin/users/${userId}`)
|
||||||
|
|
|
@ -4,7 +4,6 @@ const {
|
||||||
getUserMetadataParams,
|
getUserMetadataParams,
|
||||||
} = require("../../db/utils")
|
} = require("../../db/utils")
|
||||||
const { InternalTables } = require("../../db/utils")
|
const { InternalTables } = require("../../db/utils")
|
||||||
const { addAppRoleToUser } = require("../../utilities/workerRequests")
|
|
||||||
const { getGlobalUsers } = require("../../utilities/global")
|
const { getGlobalUsers } = require("../../utilities/global")
|
||||||
const { getFullUser } = require("../../utilities/users")
|
const { getFullUser } = require("../../utilities/users")
|
||||||
|
|
||||||
|
@ -53,9 +52,6 @@ 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 = removeGlobalProps(ctx.request.body)
|
const user = removeGlobalProps(ctx.request.body)
|
||||||
if (user.roleId) {
|
|
||||||
await addAppRoleToUser(ctx, appId, user.roleId, user._id)
|
|
||||||
}
|
|
||||||
const metadata = {
|
const metadata = {
|
||||||
tableId: InternalTables.USER_METADATA,
|
tableId: InternalTables.USER_METADATA,
|
||||||
...user,
|
...user,
|
||||||
|
|
|
@ -12,15 +12,15 @@ exports.updateAppRole = (appId, user) => {
|
||||||
if (!user.roles) {
|
if (!user.roles) {
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
if (user.builder && user.builder.global) {
|
|
||||||
user.roleId = BUILTIN_ROLE_IDS.ADMIN
|
|
||||||
} else {
|
|
||||||
// always use the deployed app
|
// always use the deployed app
|
||||||
user.roleId = user.roles[getDeployedAppID(appId)]
|
user.roleId = user.roles[getDeployedAppID(appId)]
|
||||||
if (!user.roleId) {
|
// if a role wasn't found then either set as admin (builder) or public (everyone else)
|
||||||
|
if (!user.roleId && user.builder && user.builder.global) {
|
||||||
|
user.roleId = BUILTIN_ROLE_IDS.ADMIN
|
||||||
|
} else if (!user.roleId) {
|
||||||
user.roleId = BUILTIN_ROLE_IDS.PUBLIC
|
user.roleId = BUILTIN_ROLE_IDS.PUBLIC
|
||||||
}
|
}
|
||||||
}
|
|
||||||
delete user.roles
|
delete user.roles
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@ const { EmailTemplatePurpose } = require("../../../constants")
|
||||||
const nodemailer = require("nodemailer")
|
const nodemailer = require("nodemailer")
|
||||||
const fetch = require("node-fetch")
|
const fetch = require("node-fetch")
|
||||||
|
|
||||||
|
// need a longer timeout for getting these
|
||||||
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
describe("/api/admin/email", () => {
|
describe("/api/admin/email", () => {
|
||||||
let request = setup.getRequest()
|
let request = setup.getRequest()
|
||||||
let config = setup.getConfig()
|
let config = setup.getConfig()
|
||||||
|
|
Loading…
Reference in New Issue