2
0
mirror of https://github.com/lowdefy/lowdefy.git synced 2025-04-24 16:00:53 +08:00

fix: Fixes to license validation.

This commit is contained in:
Sam Tolmay 2023-11-23 14:42:50 +02:00
parent 542892e4dd
commit 111fc20636
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions
packages
servers/server-enterprise/lib/server
utils/node-utils/src

@ -27,7 +27,7 @@ let license;
async function validateLicense() {
if (license) {
// Check cached license every 24 hours
if (license?.timestamp.valueOf?.() > Date.now() - 1000 * 60 * 60 * 24) {
if (license?.timestamp?.valueOf?.() > Date.now() - 1000 * 60 * 60 * 24) {
return license;
}
}

@ -22,12 +22,18 @@ async function keygenValidateLicense({ config }) {
const licenseKey = process.env.LOWDEFY_LICENSE_KEY;
let entitlements = [];
if (!config) {
throw new Error('License server config is not defined.');
}
// TODO: Return this or undefined/null?
if (!licenseKey) {
return {
id: 'NO_LICENSE',
code: 'NO_LICENSE',
entitlements,
metadata: {},
timestamp: new Date(),
};
}