feat(apps): Disabling apps on trial license expiration (#29037)

Co-authored-by: Tiago Evangelista Pinto <17487063+tiagoevanp@users.noreply.github.com>
pull/27866/head^2
Tasso Evangelista 3 years ago committed by GitHub
parent c58c91cb5e
commit bcde1b9dee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      apps/meteor/ee/app/license/server/license.ts
  2. 8
      apps/meteor/ee/server/apps/orchestrator.js
  3. 1
      apps/meteor/ee/server/startup/apps/index.ts
  4. 10
      apps/meteor/ee/server/startup/apps/trialExpiration.ts
  5. 1
      apps/meteor/ee/server/startup/index.ts

@ -174,7 +174,7 @@ 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;
@ -182,7 +182,7 @@ class LicenseClass {
}
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;
@ -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;
@ -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));

@ -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

@ -0,0 +1 @@
import './trialExpiration';

@ -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,4 +1,5 @@
import '../apps/startup';
import './apps';
import './audit';
import './deviceManagement';
import './engagementDashboard';

Loading…
Cancel
Save