diff --git a/packages/backend-core/src/users.ts b/packages/backend-core/src/users.ts
index 0793eeb1d9..cf055df477 100644
--- a/packages/backend-core/src/users.ts
+++ b/packages/backend-core/src/users.ts
@@ -7,6 +7,18 @@ import {
import { queryGlobalView } from "./db/views"
import { UNICODE_MAX } from "./db/constants"
import { User } from "@budibase/types"
+import { getGlobalDB } from "./context"
+import PouchDB from "pouchdb"
+
+export const bulkGetGlobalUsersById = async (userIds: string[]) => {
+ const db = getGlobalDB() as PouchDB.Database
+ return (
+ await db.allDocs({
+ keys: userIds,
+ include_docs: true,
+ })
+ ).rows.map(row => row.doc) as User[]
+}
/**
* Given an email address this will use a view to search through
diff --git a/packages/builder/src/pages/builder/portal/manage/users/index.svelte b/packages/builder/src/pages/builder/portal/manage/users/index.svelte
index df8686d25e..81d4568a15 100644
--- a/packages/builder/src/pages/builder/portal/manage/users/index.svelte
+++ b/packages/builder/src/pages/builder/portal/manage/users/index.svelte
@@ -44,6 +44,7 @@
importUsersModal
let searchEmail = undefined
let selectedRows = []
+ let bulkSaveResponse
let customRenderers = [
{ column: "userGroups", component: GroupsTableRenderer },
{ column: "apps", component: AppsTableRenderer },
@@ -166,10 +167,11 @@
async function createUsers() {
try {
- await users.create(await removingDuplicities(userData))
+ bulkSaveResponse = await users.create(await removingDuplicities(userData))
notifications.success("Successfully created user")
await groups.actions.init()
passwordModal.show()
+ await fetch.refresh()
} catch (error) {
notifications.error("Error creating user")
}
@@ -177,7 +179,7 @@
async function chooseCreationType(onboardingType) {
if (onboardingType === "emailOnboarding") {
- createUserFlow()
+ await createUserFlow()
} else {
await createUsers()
}
@@ -292,7 +294,10 @@
-
+
diff --git a/packages/builder/src/stores/portal/groups.js b/packages/builder/src/stores/portal/groups.js
index 1886bc766c..1a124f5569 100644
--- a/packages/builder/src/stores/portal/groups.js
+++ b/packages/builder/src/stores/portal/groups.js
@@ -55,12 +55,6 @@ export function createGroupsStore() {
return
}
- // Update group
- await actions.save({
- ...group,
- users: [...group.users, { _id: userId, email: user.email }],
- })
-
// Update user
let userGroups = user.userGroups || []
userGroups.push(groupId)
@@ -78,12 +72,6 @@ export function createGroupsStore() {
return
}
- // Update group
- await actions.save({
- ...group,
- users: group.users.filter(x => x._id !== userId),
- })
-
// Update user
await users.save({
...user,
diff --git a/packages/worker/src/sdk/users/users.ts b/packages/worker/src/sdk/users/users.ts
index d7556044c0..9f110a492c 100644
--- a/packages/worker/src/sdk/users/users.ts
+++ b/packages/worker/src/sdk/users/users.ts
@@ -393,7 +393,7 @@ export const bulkCreate = async (
const usersToBulkSave = await Promise.all(usersToSave)
await db.bulkDocs(usersToBulkSave)
- // Post processing of bulk added users, i.e events and cache operations
+ // Post-processing of bulk added users, e.g. events and cache operations
for (const user of usersToBulkSave) {
// TODO: Refactor to bulk insert users into the info db
// instead of relying on looping tenant creation