mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #13933 from overleaf/bg-managed-users-add-missing-jsdoc-param
refactor getUserValidationStatus in PermissionsManager GitOrigin-RevId: 80ef8142d3556e47e1d6cb323148f1f1042057aa
This commit is contained in:
parent
558992d947
commit
d2f470450e
4 changed files with 22 additions and 25 deletions
|
@ -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<Map>} 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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue