Пример #1
0
    exports.updateConditionalGrantsForUser = function(user, rolesPropName) {
        var userRoleGrants,
            existingConditionalRoles;

        userRoleGrants = relationshipHelper.getConditionalAndDirectGrants(user, rolesPropName, 'user');
        existingConditionalRoles = relationshipHelper.getConditionalRoles();
        this.evaluateConditionalRoles(user, rolesPropName, existingConditionalRoles, userRoleGrants);
    };
Пример #2
0
    /**
     * This method will constitute the set of users which satisfy the role condition.
     * @param role the newly-created conditional role
     * @returns {Array} user references which satisfy the role condition
     */
    function processCreatedConditionalRole(role) {
        var existingGrants = relationshipHelper.getConditionalAndDirectGrants(role, 'members', 'role'),
            currentConditionalGrants,
            roleMembers = [];

        currentConditionalGrants = existingGrants.conditionalGrants;
        roleMembers = roleMembers.concat(existingGrants.directGrants);

        currentConditionalGrants = processUserSet(role.condition, currentConditionalGrants, appendConditionalGrants);
        roleMembers = roleMembers.concat(currentConditionalGrants);
        return roleMembers;
    }
Пример #3
0
    /**
     * This function handles an update to a conditional role's condition (which includes the addition of a condition to
     * a non-conditional role).
     * This function will return the updated role member set. This set will be constituted as follows:
     * 1. it will include the existing, direct role members
     * 2. the existing, conditional role members will be mutated as follows:
     *      a. the users who satisfied the old condition, but do not satisfy the new condition, will be removed.
     *      b. the users who did not satisfy the old condition, but do satisfy the new condition, will be added.
     * @param oldRole the old role
     * @param newRole the updated role
     * @returns {Array} the current set of role members
     */
    function processUpdatedConditionalRole(oldRole, newRole) {
        var existingMembers = relationshipHelper.getConditionalAndDirectGrants(newRole, 'members', 'role'),
            currentConditionalGrants,
            roleGainersQuery,
            roleLosersQuery,
            roleMembers = [];

        currentConditionalGrants = existingMembers.conditionalGrants;
        roleMembers = roleMembers.concat(existingMembers.directGrants);

        roleGainersQuery = combineAndNotFirstCondition(oldRole.condition, newRole.condition);
        roleLosersQuery  = combineAndNotFirstCondition(newRole.condition, oldRole.condition);

        currentConditionalGrants = processUserSet(roleLosersQuery, currentConditionalGrants, filterConditionalGrants);
        currentConditionalGrants = processUserSet(roleGainersQuery, currentConditionalGrants, appendConditionalGrants);

        return roleMembers.concat(currentConditionalGrants);
    }
Пример #4
0
 /**
  * This function will be called when a role's condition is removed. It will return only those
  * @param newRole
  */
 function processRoleConditionRemoval(oldRole) {
     return relationshipHelper.getConditionalAndDirectGrants(oldRole, 'members', 'role').directGrants;
 }