Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions apps/meteor/ee/app/license/server/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ class LicenseClass {
return item;
}
if (!this._validateURL(license.url, this.url)) {
item.valid = false;
this.invalidate(item);
console.error(`#### License error: invalid url, licensed to ${license.url}, used on ${this.url}`);
this._invalidModules(license.modules);
return item;
}
}

if (license.expiry && this._validateExpiration(license.expiry)) {
item.valid = false;
this.invalidate(item);
console.error(`#### License error: expired, valid until ${license.expiry}`);
this._invalidModules(license.modules);
return item;
Expand Down Expand Up @@ -212,6 +212,12 @@ class LicenseClass {
this.showLicenses();
}

invalidate(item: IValidLicense): void {
item.valid = false;

EnterpriseLicenses.emit('invalidate');
}

async canAddNewUser(): Promise<boolean> {
if (!maxActiveUsers) {
return true;
Expand Down Expand Up @@ -421,6 +427,10 @@ export function onValidateLicenses(cb: (...args: any[]) => void): void {
EnterpriseLicenses.on('validate', cb);
}

export function onInvalidateLicense(cb: (...args: any[]) => void): void {
EnterpriseLicenses.on('invalidate', cb);
}

export function flatModules(modulesAndBundles: string[]): string[] {
const bundles = modulesAndBundles.filter(isBundle);
const modules = modulesAndBundles.filter((x) => !isBundle(x));
Expand Down
8 changes: 8 additions & 0 deletions apps/meteor/ee/server/apps/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ export class AppServerOrchestrator {
this._rocketchatLogger.info(`Loaded the Apps Framework and loaded a total of ${this.getManager().get({ enabled: true }).length} Apps!`);
}

async disableApps() {
await this.getManager()
.get()
.forEach((app) => {
this.getManager().disable(app.getID());
});
}

async unload() {
// Don't try to unload it if it's already been
// unlaoded or wasn't unloaded to start with
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/ee/server/startup/apps/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './trialExpiration';
10 changes: 10 additions & 0 deletions apps/meteor/ee/server/startup/apps/trialExpiration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Meteor } from 'meteor/meteor';

import { Apps } from '../../apps';
import { onInvalidateLicense } from '../../../app/license/server/license';

Meteor.startup(() => {
onInvalidateLicense(() => {
void Apps.disableApps();
});
});
1 change: 1 addition & 0 deletions apps/meteor/ee/server/startup/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../apps/startup';
import './apps';
import './audit';
import './deviceManagement';
import './engagementDashboard';
Expand Down