Skip to content

Commit cf6aeaf

Browse files
change offline license to support optional seats
1 parent fdf0256 commit cf6aeaf

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/shared/src/entitlements.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const eeLicenseKeyPrefix = "sourcebot_ee_";
1212

1313
const eeLicenseKeyPayloadSchema = z.object({
1414
id: z.string(),
15-
seats: z.number(),
15+
seats: z.number().optional(),
1616
// ISO 8601 date string
1717
expiryDate: z.string().datetime(),
1818
sig: z.string(),
@@ -84,9 +84,11 @@ export const hasEntitlement = (entitlement: Entitlement, license: License | null
8484
}
8585

8686
export const isAnonymousAccessAvailable = (license: License | null): boolean => {
87-
if (getOfflineLicenseKey()) {
88-
return false;
87+
const offlineKey = getOfflineLicenseKey();
88+
if (offlineKey) {
89+
return offlineKey.seats === undefined;
8990
}
91+
9092
if (license && isLicenseActive(license)) {
9193
return false;
9294
}

packages/web/src/lib/authUtils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const onCreateUser = async ({ user }: { user: AuthJsUser }) => {
9797
}
9898
});
9999
}
100-
100+
101101
// Subsequent users auto-join as MEMBER only when the org is in open
102102
// self-serve mode. If memberApprovalRequired is true, the user is left
103103
// without a membership and must submit an AccountRequest for an owner to
@@ -145,7 +145,11 @@ export const orgHasAvailability = async (orgId: number): Promise<boolean> => {
145145
const licenseKey = getOfflineLicenseKey();
146146
const memberCount = org.members.length;
147147

148-
if (licenseKey && memberCount >= licenseKey?.seats) {
148+
if (
149+
licenseKey &&
150+
licenseKey.seats !== undefined &&
151+
memberCount >= licenseKey.seats
152+
) {
149153
logger.error(`orgHasAvailability: org ${org.id} has reached max capacity`);
150154
return false;
151155
}

0 commit comments

Comments
 (0)