templates/sync-function/access-assignment-module.js
function assignUserAccess(doc, oldDoc, documentDefinition) {
    var effectiveOldDoc = utils.resolveOldDoc();
    var accessAssignmentDefinitions = resolveAccessAssignmentsDefinition(doc, effectiveOldDoc, documentDefinition.accessAssignments);

    var effectiveAssignments = [ ];
    for (var assignmentIndex = 0; assignmentIndex < accessAssignmentDefinitions.length; assignmentIndex++) {
      var definition = accessAssignmentDefinitions[assignmentIndex];

      if (definition.type === 'role') {
        effectiveAssignments.push(assignRolesToUsers(doc, effectiveOldDoc, definition));
      } else if (definition.type === 'channel' || utils.isValueNullOrUndefined(definition.type)) {
        effectiveAssignments.push(assignChannelsToUsersAndRoles(doc, effectiveOldDoc, definition));
      }
    }

    return effectiveAssignments;
  }
function assignUserAccess(doc, oldDoc, documentDefinition) {
    var effectiveOldDoc = utils.resolveOldDoc();
    var accessAssignmentDefinitions = resolveAccessAssignmentsDefinition(doc, effectiveOldDoc, documentDefinition.accessAssignments);

    var effectiveAssignments = [ ];
    for (var assignmentIndex = 0; assignmentIndex < accessAssignmentDefinitions.length; assignmentIndex++) {
      var definition = accessAssignmentDefinitions[assignmentIndex];

      if (definition.type === 'role') {
        effectiveAssignments.push(assignRolesToUsers(doc, effectiveOldDoc, definition));
      } else if (definition.type === 'channel' || utils.isValueNullOrUndefined(definition.type)) {
        effectiveAssignments.push(assignChannelsToUsersAndRoles(doc, effectiveOldDoc, definition));
      }
    }

    return effectiveAssignments;
  }
function assignUserAccess ( doc , oldDoc , documentDefinition ) { var effectiveOldDoc = utils . resolveOldDoc ( ) ; var accessAssignmentDefinitions = resolveAccessAssignmentsDefinition ( doc , effectiveOldDoc , documentDefinition . accessAssignments ) ; var effectiveAssignments = [ ] ; for ( var assignmentIndex = 0 ; assignmentIndex < accessAssignmentDefinitions . length ; assignmentIndex ++ ) { var definition = accessAssignmentDefinitions [ assignmentIndex ] ; if ( definition . type === 'role' ) { effectiveAssignments . push ( assignRolesToUsers ( doc , effectiveOldDoc , definition ) ) ; } else if ( definition . type === 'channel' || utils . isValueNullOrUndefined ( definition . type ) ) { effectiveAssignments . push ( assignChannelsToUsersAndRoles ( doc , effectiveOldDoc , definition ) ) ; } } return effectiveAssignments ; }
Assigns role access to users and/or channel access to users/roles according to the given access assignment definitions
Assigns role access to users and / or channel access to users / roles according to the given access assignment definitions