<commit_before>"use strict";

/*global nodeca, _*/

var User = nodeca.models.users.User;

// Validate input parameters
//
var params_schema = {
  nick: {
    type: "string",
    minLength: 1,
    required: true
  }
};
nodeca.validate(params_schema);

/**
 * users.auth.register.check_nick(params, callback) -> Void
 *
 * ##### Params
 * - nick(String):        Nickname
 *
 * Register new user
 *
 **/
module.exports = function (params, next) {
  var env = this;
  User.findOne({ 'nick': params.nick}).setOptions({ lean: true })
      .exec(function(err, doc){
    if (err) {
      next(err);
      return;
    }
    if (!_.isEmpty(doc)) {
      next({
        statusCode: 409,
        body: { nick: env.helpers.t('users.auth.reg_form.errors.nick_exists')}
      });
      return;
    }
    next();

  });
};
<commit_msg>Fixed nick basy error<commit_after>"use strict";

/*global nodeca, _*/

var User = nodeca.models.users.User;

// Validate input parameters
//
var params_schema = {
  nick: {
    type: "string",
    minLength: 1,
    required: true
  }
};
nodeca.validate(params_schema);

/**
 * users.auth.register.check_nick(params, callback) -> Void
 *
 * ##### Params
 * - nick(String):        Nickname
 *
 * Register new user
 *
 **/
module.exports = function (params, next) {
  var env = this;
  User.findOne({ 'nick': params.nick}).setOptions({ lean: true })
      .exec(function(err, doc){
    if (err) {
      next(err);
      return;
    }
    if (!_.isEmpty(doc)) {
      next({
        statusCode: 409,
        body: { nick: env.helpers.t('users.auth.reg_form.error.nick_busy')}
      });
      return;
    }
    next();

  });
};

{'fraction_non_alphanumeric': 0.17386018237082068, 'fraction_numerical': 0.004863221884498481, 'mean_word_length': 2.502127659574468, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6802520', 'n_tokens_mistral': 574, 'n_tokens_neox': 567, 'n_words': 117}