<commit_before>'use strict';
/*eslint max-statements: 0*/

var _ = require('lodash');

/**
 * The Access handler returns all the access information for the forms and roles within the project.
 *
 * @param router
 */
module.exports = function(router) {
  var hook = require('../util/hook')(router.formio);
  return function accessHandler(req, res, next) {
    // Load all the roles.
    router.formio.resources.role.model.find(hook.alter('roleQuery', {deleted: {$eq: null}}, req))
      .select({
        title: 1,
        admin: 1,
        default: 1
      })
      .exec(function(err, roleResult) {
        if (err || !roleResult) {
          return res.status(400).send('Could not load the Roles.');
        }

        var roles = {};
        _.each(roleResult, function(role) {
          roles[_.camelCase(role.title)] = role.toObject();
        });

        // Load all the forms.
        router.formio.resources.form.model.find(hook.alter('formQuery', {deleted: {$eq: null}}, req))
          .select({
            title: 1,
            name: 1,
            path: 1,<commit_msg>Make sure the role name is normalized.<commit_after>'use strict';
/*eslint max-statements: 0*/

var _ = require('lodash');

/**
 * The Access handler returns all the access information for the forms and roles within the project.
 *
 * @param router
 */
module.exports = function(router) {
  var hook = require('../util/hook')(router.formio);
  return function accessHandler(req, res, next) {
    // Load all the roles.
    router.formio.resources.role.model.find(hook.alter('roleQuery', {deleted: {$eq: null}}, req))
      .select({
        title: 1,
        admin: 1,
        default: 1
      })
      .exec(function(err, roleResult) {
        if (err || !roleResult) {
          return res.status(400).send('Could not load the Roles.');
        }

        var roles = {};
        _.each(roleResult, function(role) {
          if (role.title) {
            roles[role.title.replace(/\s/g, '').toLowerCase()] = role.toObject();
          }
        });

        // Load all the forms.
        router.formio.resources.form.model.find(hook.alter('formQuery', {deleted: {$eq: null}}, req))
          .select({
            title: 1,
            name: 1,
            path: 1,
{'fraction_non_alphanumeric': 0.15326521545979566, 'fraction_numerical': 0.00888494002665482, 'mean_word_length': 2.217142857142857, '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': '3199465', 'n_tokens_mistral': 687, 'n_tokens_neox': 671, 'n_words': 176}