<commit_before>import helpers from '../helpers';
import user from '../models';
import bcrypt from 'bcrypt';

const User = user.User;

module.exports = {
  create(req, res) {
    const username = req.body.username;
    const email = req.body.email;
    const password = req.body.password;
    const validator = /[a-z0-9]{8,}/gi
    const salt = bcrypt.genSaltSync(10);
    const hash = bcrypt.hashSync(req.body.password, salt);

    if (!validator.test(password)) {
      return res.status(400).send('Your password should be a minimum of 8 characters');
    }

    User.find({
      where: {
        username
      }
    }).then(() => {
      User.sync({ force: false }).then(() => {
        User
          .create({
            username,
            password: <PASSWORD>,
            email,
            salt
          })
          .then(newUser => res.status(201).send(newUser))
          .catch((error) => {
            res.status(400).send(error.errors[0].message);
          });
      }).catch(error => res.status(400).send(error.name));
    });
  }
};
<commit_msg>Add limit on entry passwords<commit_after>import helpers from '../helpers';
import user from '../models';
import bcrypt from 'bcrypt';

const User = user.User;

module.exports = {
  create(req, res) {
    const username = req.body.username;
    const email = req.body.email;
    const password = req.body.password;
    const validator = /[a-z0-9]{8,20}/gi
    const salt = bcrypt.genSaltSync(10);
    const hash = bcrypt.hashSync(req.body.password, salt);

    if (!validator.test(password)) {
      return res.status(400).send('Your password length should be between EIGHT and TWENTY characters long');
    }

    User.find({
      where: {
        username
      }
    }).then(() => {
      User.sync({ force: false }).then(() => {
        User
          .create({
            username,
            password: <PASSWORD>,
            email,
            salt
          })
          .then(newUser => res.status(201).send(newUser))
          .catch((error) => {
            res.status(400).send(error.errors[0].message);
          });
      }).catch(error => res.status(400).send(error.name));
    });
  }
};

{'fraction_non_alphanumeric': 0.15816091954022987, 'fraction_numerical': 0.01793103448275862, 'mean_word_length': 2.10413694721826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '331174', 'n_tokens_mistral': 681, 'n_tokens_neox': 656, 'n_words': 146}