<commit_before>
/*
 * USERS
 */

var UserModel = require('../models/User.js');
var error = require('../lib/error');

exports.query = function(req, res, next){
  UserModel.find(function(err, users){
    if (err) { return next(error); }
    res.json(users);
  });
};

exports.create = function(req, res, next){
  var user = {};
  user.password = <PASSWORD>;
  user.email = req.body.email;
  user.phone = req.body.phone;
  user.name = req.body.name;
  user.admin = req.body.admin;

  new UserModel(user).save(function(err, user){
    if (err) {
      if (err.code == 11000 || err.code == 11001) {
        return next(new error.DuplicateIndex('User with this login already exists.'));
      }
      else {
        return next(err);
      }
    }<commit_msg>create user directly from request<commit_after>
/*
 * USERS
 */

var UserModel = require('../models/User.js');
var error = require('../lib/error');

exports.query = function(req, res, next){
  UserModel.find(function(err, users){
    if (err) { return next(error); }
    res.json(users);
  });
};

exports.create = function(req, res, next){
  var user = req.body;

  new UserModel(user).save(function(err, user){
    if (err) {
      if (err.code == 11000 || err.code == 11001) {
        return next(new error.DuplicateIndex('User with this login already exists.'));
      }
      else {
        return next(err);
      }
    }
{'fraction_non_alphanumeric': 0.17246376811594202, 'fraction_numerical': 0.014492753623188406, 'mean_word_length': 2.857541899441341, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2306042', 'n_tokens_mistral': 478, 'n_tokens_neox': 458, 'n_words': 107}