<commit_before>'use strict';

/**
 * Module dependencies.
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Sites Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow([{
    roles: ['admin'],
    allows: [{
      resources: '/api/sites',
      permissions: '*'
    }, {
      resources: '/api/sites/all',
      permissions: '*'
    }, {
      resources: '/api/sites/:siteId',
      permissions: '*'
    }]
  }, {
    roles: ['user'],
    allows: [{
      resources: '/api/sites',
      permissions: ['get', 'post']
    }, {
      resources: '/api/sites/:siteId',
      permissions: ['get']
    }, {
      resources: '/api/sites/all',
      permissions: ['get']
    }]
  }, {
    roles: ['guest'],
    allows: [{
      resources: '/api/sites',
      permissions: ['get']
    }, {
      resources: '/api/sites/:siteId',
      permissions: ['get']
    }]
  }]);
};

/**
 * Check If Sites Policy Allows
 */
exports.isAllowed = function (req, res, next) {
  var roles = (req.user) ? req.user.roles : ['guest'];

  // If an sites is being processed and the current user created it then allow any manipulation
  if (req.sites && req.user && req.sites.user.id === req.user.id) {
    return next();
  }

  // Check for user roles
  acl.areAnyRolesAllowed(roles, req.route.path, req.method.toLowerCase(), function (err, isAllowed) {
    if (err) {
      // An authorization error occurred.
      return res.status(500).send('Unexpected authorization error');
    } else {
      if (isAllowed) {
        // Access granted! Invoke next middleware
        return next();
      } else {
        return res.status(403).json({
          message: 'User is not authorized'
        });
      }
    }
  });
};
<commit_msg>Allow Servers list get.<commit_after>'use strict';

/**
 * Module dependencies.
 */
var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

/**
 * Invoke Sites Permissions
 */
exports.invokeRolesPolicies = function () {
  acl.allow([{
    roles: ['admin'],
    allows: [{
      resources: '/api/sites',
      permissions: '*'
    }, {
      resources: '/api/sites/all',
      permissions: '*'
    }, {
      resources: '/api/sites/:siteId',
      permissions: '*'
    }]
  }, {
    roles: ['user'],
    allows: [{
      resources: '/api/sites',
      permissions: ['get', 'post']
    }, {
      resources: '/api/sites/:siteId',
      permissions: ['get']
    }, {
      resources: '/api/sites/all',
      permissions: ['get']
    }]
  }, {
    roles: ['guest'],
    allows: [{
      resources: '/api/sites',
      permissions: ['get']
    }, {
      resources: '/api/sites/all',
      permissions: ['get']
    }, {
      resources: '/api/sites/:siteId',
      permissions: ['get']
    }]
  }]);
};

/**
 * Check If Sites Policy Allows
 */
exports.isAllowed = function (req, res, next) {
  var roles = (req.user) ? req.user.roles : ['guest'];

  // If an sites is being processed and the current user created it then allow any manipulation
  if (req.sites && req.user && req.sites.user.id === req.user.id) {
    return next();
  }

  // Check for user roles
  acl.areAnyRolesAllowed(roles, req.route.path, req.method.toLowerCase(), function (err, isAllowed) {
    if (err) {
      // An authorization error occurred.
      return res.status(500).send('Unexpected authorization error');
    } else {
      if (isAllowed) {
        // Access granted! Invoke next middleware
        return next();
      } else {
        return res.status(403).json({
          message: 'User is not authorized'
        });
      }
    }
  });
};

{'fraction_non_alphanumeric': 0.17529443987948506, 'fraction_numerical': 0.003286770747740345, 'mean_word_length': 2.301989150090416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3309506', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1165, 'n_words': 279}