diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/ImportUsersModal.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/ImportUsersModal.svelte index be0023ec21..b35c6c998f 100644 --- a/packages/builder/src/pages/builder/portal/users/users/_components/ImportUsersModal.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/_components/ImportUsersModal.svelte @@ -25,7 +25,7 @@ $: invalidEmails = [] $: userCount = $licensing.userCount + userEmails.length - $: willExceed = userCount > $licensing.userLimit + $: willExceed = licensing.willExceedUserLimit(userCount) $: importDisabled = !userEmails.length || !validEmails(userEmails) || !usersRole || willExceed diff --git a/packages/builder/src/stores/portal/users.js b/packages/builder/src/stores/portal/users.js index d223239f67..898d47c0e2 100644 --- a/packages/builder/src/stores/portal/users.js +++ b/packages/builder/src/stores/portal/users.js @@ -114,11 +114,13 @@ export function createUsersStore() { const getUserRole = ({ admin, builder }) => admin?.global ? "admin" : builder?.global ? "developer" : "appUser" - const refreshUsage = fn => async args => { - const response = await fn(args) - await licensing.setQuotaUsage() - return response - } + const refreshUsage = + fn => + async (...args) => { + const response = await fn(...args) + await licensing.setQuotaUsage() + return response + } return { subscribe, @@ -133,7 +135,7 @@ export function createUsersStore() { updateInvite, getUserCountByApp, // any operation that adds or deletes users - acceptInvite: refreshUsage(acceptInvite), + acceptInvite, create: refreshUsage(create), save: refreshUsage(save), bulkDelete: refreshUsage(bulkDelete), diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts index 8db2d29691..d9ebc87517 100644 --- a/packages/worker/src/api/controllers/global/users.ts +++ b/packages/worker/src/api/controllers/global/users.ts @@ -424,7 +424,9 @@ export const inviteAccept = async ( if (err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) { // explicitly re-throw limit exceeded errors ctx.throw(400, err) + return } + console.warn("Error inviting user", err) ctx.throw(400, "Unable to create new user, invitation invalid.") } } diff --git a/packages/worker/src/sdk/accounts/metadata.ts b/packages/worker/src/sdk/accounts/metadata.ts index 64065e8b78..11ab069839 100644 --- a/packages/worker/src/sdk/accounts/metadata.ts +++ b/packages/worker/src/sdk/accounts/metadata.ts @@ -18,8 +18,17 @@ export const saveMetadata = async ( if (existing) { metadata._rev = existing._rev } - const res = await db.put(metadata) - metadata._rev = res.rev + try { + const res = await db.put(metadata) + metadata._rev = res.rev + } catch (e: any) { + // account can be updated frequently + // ignore 409 + if (e.status !== 409) { + throw e + } + } + return metadata }) }