[draft] Pricing/fixes (#10424)
* Fix qa core suite * Update package.json * Lint * Handle conflict on account metadata * Fix issue adding users via csv import when on paid plan * Fix user invites * Lint
This commit is contained in:
parent
34b0a1fa2d
commit
972e2257b7
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue