diff --git a/packages/builder/src/pages/builder/portal/users/users/index.svelte b/packages/builder/src/pages/builder/portal/users/users/index.svelte
index c2fbce5747..58da310104 100644
--- a/packages/builder/src/pages/builder/portal/users/users/index.svelte
+++ b/packages/builder/src/pages/builder/portal/users/users/index.svelte
@@ -60,6 +60,7 @@
userLimitReachedModal
let searchEmail = undefined
let selectedRows = []
+ let selectedInvites = []
let bulkSaveResponse
let customRenderers = [
{ column: "email", component: EmailTableRenderer },
@@ -123,7 +124,7 @@
return {}
}
let pendingSchema = JSON.parse(JSON.stringify(tblSchema))
- pendingSchema.email.displayName = "Pending Invites"
+ pendingSchema.email.displayName = "Pending Users"
return pendingSchema
}
@@ -132,6 +133,7 @@
const { admin, builder, userGroups, apps } = invite.info
return {
+ _id: invite.code,
email: invite.email,
builder,
admin,
@@ -260,9 +262,26 @@
return
}
- await users.bulkDelete(ids)
- notifications.success(`Successfully deleted ${selectedRows.length} rows`)
+ if (ids.length > 0) {
+ await users.bulkDelete(ids)
+ }
+
+ if (selectedInvites.length > 0) {
+ await users.removeInvites(
+ selectedInvites.map(invite => ({
+ code: invite._id,
+ }))
+ )
+ pendingInvites = await users.getInvites()
+ }
+
+ notifications.success(
+ `Successfully deleted ${
+ selectedRows.length + selectedInvites.length
+ } users`
+ )
selectedRows = []
+ selectedInvites = []
await fetch.refresh()
} catch (error) {
notifications.error("Error deleting users")
@@ -328,15 +347,15 @@
{/if}
-
- {#if selectedRows.length > 0}
+ {#if selectedRows.length > 0 || selectedInvites.length > 0}
{/if}
+
({
})
},
+ /**
+ * Removes multiple user invites from Redis cache
+ */
+ removeUserInvites: async inviteCodes => {
+ return await API.post({
+ url: "/api/global/users/multi/invite/delete",
+ body: inviteCodes,
+ })
+ },
+
/**
* Accepts an invite to join the platform and creates a user.
* @param inviteCode the invite code sent in the email
diff --git a/packages/types/src/api/web/user.ts b/packages/types/src/api/web/user.ts
index f59bda133b..471ca86616 100644
--- a/packages/types/src/api/web/user.ts
+++ b/packages/types/src/api/web/user.ts
@@ -45,7 +45,12 @@ export interface InviteUserRequest {
userInfo: any
}
+export interface DeleteInviteUserRequest {
+ code: string
+}
+
export type InviteUsersRequest = InviteUserRequest[]
+export type DeleteInviteUsersRequest = DeleteInviteUserRequest[]
export interface InviteUsersResponse {
successful: { email: string }[]
diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts
index 46bf13284e..cd69281f56 100644
--- a/packages/worker/src/api/controllers/global/users.ts
+++ b/packages/worker/src/api/controllers/global/users.ts
@@ -10,6 +10,8 @@ import {
CreateAdminUserRequest,
CreateAdminUserResponse,
Ctx,
+ DeleteInviteUserRequest,
+ DeleteInviteUsersRequest,
InviteUserRequest,
InviteUsersRequest,
InviteUsersResponse,
@@ -335,6 +337,20 @@ export const inviteMultiple = async (ctx: Ctx) => {
ctx.body = await userSdk.invite(ctx.request.body)
}
+export const removeMultipleInvites = async (
+ ctx: Ctx
+) => {
+ const inviteCodesToRemove = ctx.request.body.map(
+ (invite: DeleteInviteUserRequest) => invite.code
+ )
+ for (const code of inviteCodesToRemove) {
+ await cache.invite.deleteCode(code)
+ }
+ ctx.body = {
+ message: "User invites successfully removed.",
+ }
+}
+
export const checkInvite = async (ctx: any) => {
const { code } = ctx.params
let invite
diff --git a/packages/worker/src/api/routes/global/users.ts b/packages/worker/src/api/routes/global/users.ts
index b40c491830..0372c187f8 100644
--- a/packages/worker/src/api/routes/global/users.ts
+++ b/packages/worker/src/api/routes/global/users.ts
@@ -108,6 +108,11 @@ router
buildInviteMultipleValidation(),
controller.inviteMultiple
)
+ .post(
+ "/api/global/users/multi/invite/delete",
+ auth.builderOrAdmin,
+ controller.removeMultipleInvites
+ )
// non-global endpoints
.get("/api/global/users/invite/:code", controller.checkInvite)
diff --git a/yarn.lock b/yarn.lock
index 677b7cb441..9daf499918 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -11904,6 +11904,17 @@ glob@^10.0.0, glob@^10.2.2:
minipass "^7.0.4"
path-scurry "^1.10.2"
+glob@^10.3.7:
+ version "10.4.1"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.1.tgz#0cfb01ab6a6b438177bfe6a58e2576f6efe909c2"
+ integrity sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==
+ dependencies:
+ foreground-child "^3.1.0"
+ jackspeak "^3.1.2"
+ minimatch "^9.0.4"
+ minipass "^7.1.2"
+ path-scurry "^1.11.1"
+
glob@^5.0.15:
version "5.0.15"
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
@@ -13472,6 +13483,15 @@ jackspeak@^2.3.6:
optionalDependencies:
"@pkgjs/parseargs" "^0.11.0"
+jackspeak@^3.1.2:
+ version "3.1.2"
+ resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.1.2.tgz#eada67ea949c6b71de50f1b09c92a961897b90ab"
+ integrity sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==
+ dependencies:
+ "@isaacs/cliui" "^8.0.2"
+ optionalDependencies:
+ "@pkgjs/parseargs" "^0.11.0"
+
jake@^10.8.5:
version "10.8.5"
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46"
@@ -15751,6 +15771,13 @@ minimatch@^8.0.2:
dependencies:
brace-expansion "^2.0.1"
+minimatch@^9.0.4:
+ version "9.0.4"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51"
+ integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==
+ dependencies:
+ brace-expansion "^2.0.1"
+
minimist-options@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619"
@@ -15845,6 +15872,11 @@ minipass@^5.0.0:
resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c"
integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==
+minipass@^7.1.2:
+ version "7.1.2"
+ resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.2.tgz#93a9626ce5e5e66bd4db86849e7515e92340a707"
+ integrity sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==
+
minizlib@^2.1.1, minizlib@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931"
@@ -17378,6 +17410,14 @@ path-scurry@^1.10.2, path-scurry@^1.6.1:
lru-cache "^10.2.0"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
+path-scurry@^1.11.1:
+ version "1.11.1"
+ resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.11.1.tgz#7960a668888594a0720b12a911d1a742ab9f11d2"
+ integrity sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==
+ dependencies:
+ lru-cache "^10.2.0"
+ minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
+
path-to-regexp@1.x:
version "1.8.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
@@ -19318,6 +19358,13 @@ rimraf@^4.4.1:
dependencies:
glob "^9.2.0"
+rimraf@^5.0.7:
+ version "5.0.7"
+ resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.7.tgz#27bddf202e7d89cb2e0381656380d1734a854a74"
+ integrity sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==
+ dependencies:
+ glob "^10.3.7"
+
ripemd160@^2.0.0, ripemd160@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c"