-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Pierre Lehnen <[email protected]> Co-authored-by: Guilherme Gazzo <[email protected]>
- Loading branch information
1 parent
2872428
commit 5f81a0f
Showing
129 changed files
with
2,687 additions
and
1,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
'@rocket.chat/license': minor | ||
'@rocket.chat/jwt': minor | ||
'@rocket.chat/omnichannel-services': minor | ||
'@rocket.chat/omnichannel-transcript': minor | ||
'@rocket.chat/authorization-service': minor | ||
'@rocket.chat/stream-hub-service': minor | ||
'@rocket.chat/presence-service': minor | ||
'@rocket.chat/account-service': minor | ||
'@rocket.chat/core-services': minor | ||
'@rocket.chat/model-typings': minor | ||
'@rocket.chat/core-typings': minor | ||
'@rocket.chat/rest-typings': minor | ||
'@rocket.chat/ddp-streamer': minor | ||
'@rocket.chat/queue-worker': minor | ||
'@rocket.chat/presence': minor | ||
'@rocket.chat/meteor': minor | ||
--- | ||
|
||
Implemented the License library, it is used to handle the functionality like expiration date, modules, limits, etc. | ||
Also added a version v3 of the license, which contains an extended list of features. | ||
v2 is still supported, since we convert it to v3 on the fly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { onLicense } from '../../license/server'; | ||
import { License } from '@rocket.chat/license'; | ||
|
||
await onLicense('canned-responses', async () => { | ||
await License.onLicense('canned-responses', async () => { | ||
await import('./canned-responses'); | ||
}); |
29 changes: 0 additions & 29 deletions
29
apps/meteor/ee/app/authorization/server/validateUserRoles.js
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
apps/meteor/ee/app/authorization/server/validateUserRoles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { IUser } from '@rocket.chat/core-typings'; | ||
import { License } from '@rocket.chat/license'; | ||
import { Users } from '@rocket.chat/models'; | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
import { i18n } from '../../../../server/lib/i18n'; | ||
|
||
export const validateUserRoles = async function (userData: Partial<IUser>) { | ||
if (!License.hasValidLicense()) { | ||
return; | ||
} | ||
|
||
const isGuest = Boolean(userData.roles?.includes('guest') && userData.roles.length === 1); | ||
const currentUserData = userData._id ? await Users.findOneById(userData._id) : null; | ||
const wasGuest = Boolean(currentUserData?.roles?.includes('guest') && currentUserData.roles.length === 1); | ||
|
||
if (currentUserData?.type === 'app') { | ||
return; | ||
} | ||
|
||
if (isGuest) { | ||
if (wasGuest) { | ||
return; | ||
} | ||
|
||
if (await License.shouldPreventAction('guestUsers')) { | ||
throw new Meteor.Error('error-max-guests-number-reached', 'Maximum number of guests reached.', { | ||
method: 'insertOrUpdateUser', | ||
field: 'Assign_role', | ||
}); | ||
} | ||
|
||
return; | ||
} | ||
|
||
if (!wasGuest && userData._id) { | ||
return; | ||
} | ||
|
||
if (await License.shouldPreventAction('activeUsers')) { | ||
throw new Meteor.Error('error-license-user-limit-reached', i18n.t('error-license-user-limit-reached')); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage'; | ||
import { Apps } from '@rocket.chat/core-services'; | ||
import { License } from '@rocket.chat/license'; | ||
|
||
import { getInstallationSourceFromAppStorageItem } from '../../../../lib/apps/getInstallationSourceFromAppStorageItem'; | ||
|
||
export const canEnableApp = async (app: IAppStorageItem): Promise<boolean> => { | ||
if (!(await Apps.isInitialized())) { | ||
return false; | ||
} | ||
|
||
// Migrated apps were installed before the validation was implemented | ||
// so they're always allowed to be enabled | ||
if (app.migrated) { | ||
return true; | ||
} | ||
|
||
const source = getInstallationSourceFromAppStorageItem(app); | ||
switch (source) { | ||
case 'private': | ||
return !(await License.shouldPreventAction('privateApps')); | ||
default: | ||
return !(await License.shouldPreventAction('marketplaceApps')); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Apps } from '@rocket.chat/core-services'; | ||
import type { LicenseAppSources } from '@rocket.chat/license'; | ||
|
||
import { getInstallationSourceFromAppStorageItem } from '../../../../../lib/apps/getInstallationSourceFromAppStorageItem'; | ||
|
||
export async function getAppCount(source: LicenseAppSources): Promise<number> { | ||
if (!(await Apps.isInitialized())) { | ||
return 0; | ||
} | ||
|
||
const apps = await Apps.getApps({ enabled: true }); | ||
|
||
if (!apps || !Array.isArray(apps)) { | ||
return 0; | ||
} | ||
|
||
const storageItems = await Promise.all(apps.map((app) => Apps.getAppStorageItemById(app.id))); | ||
const activeAppsFromSameSource = storageItems.filter((item) => item && getInstallationSourceFromAppStorageItem(item) === source); | ||
|
||
return activeAppsFromSameSource.length; | ||
} |
This file was deleted.
Oops, something went wrong.
20 changes: 10 additions & 10 deletions
20
apps/meteor/ee/app/license/server/license.internalService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.