Fix issue around adding of admin users
This commit is contained in:
parent
190e29e043
commit
24abd91600
|
@ -366,18 +366,21 @@
|
||||||
const payload = [
|
const payload = [
|
||||||
{
|
{
|
||||||
email: newUserEmail,
|
email: newUserEmail,
|
||||||
builder: !!creationRoleType === Constants.BudibaseRoles.Admin,
|
builder: creationRoleType === Constants.BudibaseRoles.Admin,
|
||||||
admin: !!creationRoleType === Constants.BudibaseRoles.Admin,
|
admin: creationRoleType === Constants.BudibaseRoles.Admin,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
if (creationAccessType === Constants.Roles.CREATOR) {
|
if (creationRoleType !== Constants.BudibaseRoles.Admin) {
|
||||||
payload[0].appBuilders = [prodAppId]
|
if (creationAccessType === Constants.Roles.CREATOR) {
|
||||||
} else {
|
payload[0].appBuilders = [prodAppId]
|
||||||
payload[0].apps = {
|
} else {
|
||||||
[prodAppId]: creationAccessType,
|
payload[0].apps = {
|
||||||
|
[prodAppId]: creationAccessType,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let userInviteResponse
|
let userInviteResponse
|
||||||
try {
|
try {
|
||||||
userInviteResponse = await users.onboard(payload)
|
userInviteResponse = await users.onboard(payload)
|
||||||
|
@ -494,6 +497,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getInviteRoleValue = invite => {
|
||||||
|
if (invite.info?.admin?.global && invite.info?.builder?.global) {
|
||||||
|
return Constants.Roles.ADMIN
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invite.info?.appBuilders?.includes(prodAppId)) {
|
||||||
|
return Constants.Roles.CREATOR
|
||||||
|
}
|
||||||
|
|
||||||
|
return invite.info.apps?.[prodAppId]
|
||||||
|
}
|
||||||
|
|
||||||
const getRoleFooter = user => {
|
const getRoleFooter = user => {
|
||||||
if (user.group) {
|
if (user.group) {
|
||||||
const role = $roles.find(role => role._id === user.role)
|
const role = $roles.find(role => role._id === user.role)
|
||||||
|
@ -600,6 +615,11 @@
|
||||||
<div class="auth-entity-access-title">Access</div>
|
<div class="auth-entity-access-title">Access</div>
|
||||||
</div>
|
</div>
|
||||||
{#each filteredInvites as invite}
|
{#each filteredInvites as invite}
|
||||||
|
{@const user = {
|
||||||
|
isAdminOrGlobalBuilder:
|
||||||
|
invite.info?.admin?.global && invite.info?.builder?.global,
|
||||||
|
}}
|
||||||
|
|
||||||
<div class="auth-entity">
|
<div class="auth-entity">
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<div class="user-email" title={invite.email}>
|
<div class="user-email" title={invite.email}>
|
||||||
|
@ -608,10 +628,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="auth-entity-access">
|
<div class="auth-entity-access">
|
||||||
<RoleSelect
|
<RoleSelect
|
||||||
|
footer={getRoleFooter(user)}
|
||||||
placeholder={false}
|
placeholder={false}
|
||||||
value={invite.info?.appBuilders?.includes(prodAppId)
|
value={getInviteRoleValue(invite)}
|
||||||
? Constants.Roles.CREATOR
|
|
||||||
: invite.info.apps?.[prodAppId]}
|
|
||||||
allowRemove={invite.info.apps?.[prodAppId]}
|
allowRemove={invite.info.apps?.[prodAppId]}
|
||||||
allowPublic={false}
|
allowPublic={false}
|
||||||
allowCreator={true}
|
allowCreator={true}
|
||||||
|
@ -624,6 +643,9 @@
|
||||||
}}
|
}}
|
||||||
autoWidth
|
autoWidth
|
||||||
align="right"
|
align="right"
|
||||||
|
allowedRoles={user.isAdminOrGlobalBuilder
|
||||||
|
? [Constants.Roles.ADMIN]
|
||||||
|
: null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -153,10 +153,13 @@ export const buildUserEndpoints = API => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onboardUsers: async payload => {
|
onboardUsers: async payload => {
|
||||||
|
console.log(payload)
|
||||||
return await API.post({
|
return await API.post({
|
||||||
url: "/api/global/users/onboard",
|
url: "/api/global/users/onboard",
|
||||||
body: payload.map(invite => {
|
body: payload.map(invite => {
|
||||||
const { email, admin, builder, apps, appBuilders } = invite
|
const { email, admin, builder, apps, appBuilders } = invite
|
||||||
|
console.log(admin)
|
||||||
|
console.log(builder)
|
||||||
return {
|
return {
|
||||||
email,
|
email,
|
||||||
userInfo: {
|
userInfo: {
|
||||||
|
|
|
@ -266,7 +266,9 @@ export const onboardUsers = async (ctx: Ctx<InviteUsersRequest>) => {
|
||||||
|
|
||||||
// Temp password to be passed to the user.
|
// Temp password to be passed to the user.
|
||||||
createdPasswords[invite.email] = password
|
createdPasswords[invite.email] = password
|
||||||
let builder: { global: boolean; apps?: string[] } = { global: false }
|
let builder: { global: boolean; apps?: string[] } = {
|
||||||
|
global: invite.userInfo.builder || false,
|
||||||
|
}
|
||||||
if (invite.userInfo.appBuilders) {
|
if (invite.userInfo.appBuilders) {
|
||||||
builder.apps = invite.userInfo.appBuilders
|
builder.apps = invite.userInfo.appBuilders
|
||||||
}
|
}
|
||||||
|
@ -275,7 +277,7 @@ export const onboardUsers = async (ctx: Ctx<InviteUsersRequest>) => {
|
||||||
password,
|
password,
|
||||||
forceResetPassword: true,
|
forceResetPassword: true,
|
||||||
roles: invite.userInfo.apps,
|
roles: invite.userInfo.apps,
|
||||||
admin: { global: false },
|
admin: { global: invite.userInfo.admin || false },
|
||||||
builder,
|
builder,
|
||||||
tenantId: tenancy.getTenantId(),
|
tenantId: tenancy.getTenantId(),
|
||||||
}
|
}
|
||||||
|
@ -409,10 +411,13 @@ export const inviteAccept = async (
|
||||||
lastName,
|
lastName,
|
||||||
password,
|
password,
|
||||||
email,
|
email,
|
||||||
|
admin: { global: info.admin || false },
|
||||||
roles: info.apps,
|
roles: info.apps,
|
||||||
tenantId: info.tenantId,
|
tenantId: info.tenantId,
|
||||||
}
|
}
|
||||||
let builder: { global: boolean; apps?: string[] } = { global: false }
|
let builder: { global: boolean; apps?: string[] } = {
|
||||||
|
global: info.builder || false,
|
||||||
|
}
|
||||||
|
|
||||||
if (info.appBuilders) {
|
if (info.appBuilders) {
|
||||||
builder.apps = info.appBuilders
|
builder.apps = info.appBuilders
|
||||||
|
|
Loading…
Reference in New Issue