diff --git a/services/web/app/src/Features/Authorization/PermissionsManager.js b/services/web/app/src/Features/Authorization/PermissionsManager.js index bf511673b9..a15110deef 100644 --- a/services/web/app/src/Features/Authorization/PermissionsManager.js +++ b/services/web/app/src/Features/Authorization/PermissionsManager.js @@ -282,17 +282,19 @@ function hasPermission(groupPolicy, capability) { /** * Asynchronously checks which policies a user complies with using the - * applicable validators. Each validator is an async function that takes a object - * with user and subscription properties and returns a boolean. + * applicable validators. Each validator is an async function that takes an object + * with user, groupPolicy, and subscription properties and returns a boolean. * - * @param {Object} user - The user object to check. - * @param {Object} groupPolicy - The group policy object to check. + * @param {Object} options - The options object. + * @param {Object} options.user - The user object to check. + * @param {Object} options.groupPolicy - The group policy object to check. + * @param {Object} options.subscription - The subscription object for the group policy. * @returns {Promise} A promise that resolves with a Map object containing * the validation status for each enforced policy. The keys of the Map are the * enforced policy names, and the values are booleans indicating whether the * user complies with the policy. */ -async function getUserValidationStatus(user, groupPolicy, subscription) { +async function getUserValidationStatus({ user, groupPolicy, subscription }) { // find all the enforced policies for the user const enforcedPolicyNames = getEnforcedPolicyNames(groupPolicy) // for each enforced policy, we have a list of capabilities with expected values diff --git a/services/web/app/src/Features/Subscription/TeamInvitesController.js b/services/web/app/src/Features/Subscription/TeamInvitesController.js index ee2e58ee11..774a365693 100644 --- a/services/web/app/src/Features/Subscription/TeamInvitesController.js +++ b/services/web/app/src/Features/Subscription/TeamInvitesController.js @@ -93,11 +93,11 @@ async function viewInvite(req, res, next) { } validationStatus = - await PermissionsManager.promises.getUserValidationStatus( + await PermissionsManager.promises.getUserValidationStatus({ user, - subscription.groupPolicy, - subscription - ) + groupPolicy: subscription.groupPolicy, + subscription, + }) return res.render('subscriptions/team/invite-managed', { inviterName: invite.inviterName, diff --git a/services/web/test/acceptance/src/helpers/Subscription.js b/services/web/test/acceptance/src/helpers/Subscription.js index d5b9beaa59..1493964209 100644 --- a/services/web/test/acceptance/src/helpers/Subscription.js +++ b/services/web/test/acceptance/src/helpers/Subscription.js @@ -74,13 +74,8 @@ class Subscription { return PermissionsManager.getUserCapabilities(groupPolicy) } - getUserValidationStatus(user, groupPolicy, subscription, callback) { - PermissionsManager.getUserValidationStatus( - user, - groupPolicy, - subscription, - callback - ) + getUserValidationStatus(params, callback) { + PermissionsManager.getUserValidationStatus(params, callback) } enrollManagedUser(user, callback) { diff --git a/services/web/test/unit/src/Authorization/PermissionsManagerTests.js b/services/web/test/unit/src/Authorization/PermissionsManagerTests.js index 0dde24b834..9115dd8b38 100644 --- a/services/web/test/unit/src/Authorization/PermissionsManagerTests.js +++ b/services/web/test/unit/src/Authorization/PermissionsManagerTests.js @@ -288,11 +288,11 @@ describe('PermissionsManager', function () { const user = { prop: 'allowed' } const subscription = { prop: 'managed' } const result = - await this.PermissionsManager.promises.getUserValidationStatus( + await this.PermissionsManager.promises.getUserValidationStatus({ user, groupPolicy, - subscription - ) + subscription, + }) expect(result).to.deep.equal(new Map([['policy', true]])) }) @@ -312,11 +312,11 @@ describe('PermissionsManager', function () { const user = { prop: 'not allowed' } const subscription = { prop: 'managed' } const result = - await this.PermissionsManager.promises.getUserValidationStatus( + await this.PermissionsManager.promises.getUserValidationStatus({ user, groupPolicy, - subscription - ) + subscription, + }) expect(result).to.deep.equal(new Map([['policy', false]])) }) it('should return the status for multiple policies according to whether the user conforms', async function () { @@ -356,11 +356,11 @@ describe('PermissionsManager', function () { const user = { prop: 'allowed' } const subscription = { prop: 'managed' } const result = - await this.PermissionsManager.promises.getUserValidationStatus( + await this.PermissionsManager.promises.getUserValidationStatus({ user, groupPolicy, - subscription - ) + subscription, + }) expect(result).to.deep.equal( new Map([ ['policy1', true],