feat(gatekeeper): require a license for billing
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
const EnabledModules = z.object({
|
||||
workspaces: z.boolean(),
|
||||
gatekeeper: z.boolean()
|
||||
})
|
||||
const EnabledModules = z
|
||||
.object({
|
||||
workspaces: z.boolean(),
|
||||
gatekeeper: z.boolean(),
|
||||
billing: z.boolean()
|
||||
})
|
||||
.partial()
|
||||
|
||||
export type EnabledModules = z.infer<typeof EnabledModules>
|
||||
|
||||
|
||||
@@ -19,9 +19,19 @@ const gatekeeperModule: SpeckleModule = {
|
||||
)
|
||||
|
||||
if (isInitial) {
|
||||
if (FF_BILLING_INTEGRATION_ENABLED) app.use(billingRouter)
|
||||
// TODO: need to subscribe to the workspaceCreated event and store the workspacePlan as a trial if billing enabled, else store as unlimited
|
||||
// TODO: create a cron job, that removes unused seats from the subscription at the beginning of each workspace plan's billing cycle
|
||||
if (FF_BILLING_INTEGRATION_ENABLED) {
|
||||
app.use(billingRouter)
|
||||
|
||||
const isLicenseValid = await validateModuleLicense({
|
||||
requiredModules: ['billing']
|
||||
})
|
||||
if (!isLicenseValid)
|
||||
throw new Error(
|
||||
'The the billing module needs a valid license to run, contact Speckle to get one.'
|
||||
)
|
||||
// TODO: create a cron job, that removes unused seats from the subscription at the beginning of each workspace plan's billing cycle
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ describe('validateLicense @gatekeeper', () => {
|
||||
licenseToken,
|
||||
canonicalUrl,
|
||||
publicKey,
|
||||
requiredModules: ['workspaces']
|
||||
requiredModules: ['workspaces', 'gatekeeper']
|
||||
})
|
||||
|
||||
expect(result).to.be.false
|
||||
|
||||
Reference in New Issue
Block a user