feat(gatekeeper): require a license for billing

This commit is contained in:
Gergő Jedlicska
2024-10-17 12:11:22 +02:00
parent 1ceca7369a
commit 49128192de
3 changed files with 20 additions and 7 deletions
@@ -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>
+12 -2
View File
@@ -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