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