<commit_before>
var User = require('../../models/user/user.model');

module.exports = function (req, res, next) {
	User.findOne({$or: [{username: req.body.username}, {email: req.body.email}]}, function (err, user) {
		if (err) return res.status(500).json({message: 'Internal server error'});
		if (user) {
			if (user.username === req.body.username) return res.status(409).json({message: 'Username already exists'});
			if (user.email === req.body.email) return res.status(409).json({message: 'Email already exists'});
		}
		next();
	});
};<commit_msg>unqique.validator now checks on lowercase.<commit_after>
var User = require('../../models/user/user.model');

module.exports = function (req, res, next) {
	User.findOne({$or: [{username: req.body.username.toLowerCase()}, {email: req.body.email.toLowerCase()}]}, function (err, user) {
		if (err) return res.status(500).json({message: 'Internal server error'});
		if (user) {
			if (user.username === req.body.username) return res.status(409).json({message: 'Username already exists'});
			if (user.email === req.body.email) return res.status(409).json({message: 'Email already exists'});
		}
		next();
	});
};
{'fraction_non_alphanumeric': 0.2049956933677864, 'fraction_numerical': 0.015503875968992248, 'mean_word_length': 4.781094527363184, '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': '7138956', 'n_tokens_mistral': 400, 'n_tokens_neox': 376, 'n_words': 90}