<commit_before>var bcrypt = require('bcrypt');

module.exports = function(sequelize, DataTypes) {
  var name = 'User';

  var attributes = {
    username: {
      type: DataTypes.STRING,
      unique: true
    },
    firstName: {
      type: DataTypes.STRING,
    },
    lastName: {
      type: DataTypes.STRING,
    },
    email: {
      type: DataTypes.STRING,
      validate: { isEmail: true },
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    superuser: {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
    }
  };

  const publicFields = Object.freeze([
    'id',
    'username',
  ]);

  var getAll = async function(where) {
    return await this.findAll({
      where: where,
      attributes: publicFields,
    });
  };

  var options = {
    classMethods: {
      addAssociations: addAssociations,
      apiSettableFields: apiSettableFields,
      getAll: getAll,
    },
    instanceMethods: {
      comparePassword: comparePassword,
      getGroupsIds: getGroupsIds,
      getDeviceIds: getDeviceIds,
      getJwtDataValues: getJwtDataValues,
      getDataValues: getDataValues,
      getAll: getAll,
    },
    hooks: {
      afterValidate: afterValidate
    }
  };
  // Define table
  return sequelize.define(name, attributes, options);
};

var apiSettableFields = [
  'firstName',
  'lastName'
];

function getJwtDataValues() {
  return {
    id: this.getDataValue('id'),
    _type: 'user'
  };
}

function getDataValues() {
  var user = this;
  return new Promise(function(resolve, reject) {
    user.getGroups()
      .then(function(groups) {
        resolve({
          username: user.getDataValue('username'),
          firstName: user.getDataValue('firstName'),
          lastName: user.getDataValue('lastName'),
          email: user.getDataValue('email'),
          groups: groups
        });
      });
  });
}
<commit_msg>Added user ID to JWT data.<commit_after>var bcrypt = require('bcrypt');

module.exports = function(sequelize, DataTypes) {
  var name = 'User';

  var attributes = {
    username: {
      type: DataTypes.STRING,
      unique: true
    },
    firstName: {
      type: DataTypes.STRING,
    },
    lastName: {
      type: DataTypes.STRING,
    },
    email: {
      type: DataTypes.STRING,
      validate: { isEmail: true },
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    superuser: {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
    }
  };

  const publicFields = Object.freeze([
    'id',
    'username',
  ]);

  var getAll = async function(where) {
    return await this.findAll({
      where: where,
      attributes: publicFields,
    });
  };

  var options = {
    classMethods: {
      addAssociations: addAssociations,
      apiSettableFields: apiSettableFields,
      getAll: getAll,
    },
    instanceMethods: {
      comparePassword: comparePassword,
      getGroupsIds: getGroupsIds,
      getDeviceIds: getDeviceIds,
      getJwtDataValues: getJwtDataValues,
      getDataValues: getDataValues,
      getAll: getAll,
    },
    hooks: {
      afterValidate: afterValidate
    }
  };
  // Define table
  return sequelize.define(name, attributes, options);
};

var apiSettableFields = [
  'firstName',
  'lastName'
];

function getJwtDataValues() {
  return {
    id: this.getDataValue('id'),
    _type: 'user'
  };
}

function getDataValues() {
  var user = this;
  return new Promise(function(resolve, reject) {
    user.getGroups()
      .then(function(groups) {
        resolve({
          id: user.getDataValue('id'),
          username: user.getDataValue('username'),
          firstName: user.getDataValue('firstName'),
          lastName: user.getDataValue('lastName'),
          email: user.getDataValue('email'),
          groups: groups
        });
      });
  });
}

{'fraction_non_alphanumeric': 0.12304483837330553, 'fraction_numerical': 0.0, 'mean_word_length': 2.4629963898916967, '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': '2170880', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1192, 'n_words': 243}