<commit_before>// dependencies ------------------------------------------------------------

import scitran  from '../libs/scitran';
import sanitize from '../libs/sanitize';
import mongo    from '../libs/mongo';

let c = mongo.collections;

// models ------------------------------------------------------------------

let models = {
	newUser: {
		_id:       'string, required',
		firstname: 'string, required',
		lastname:  'string, required'
	},
	blacklistUser: {
		_id:       'string, required',
		firstname: 'string',
		lastname:  'string',
		note:      'string'
	}
}

// handlers ----------------------------------------------------------------

/**
 * Users
 *
 * Handlers for user actions.
 */
export default {


	// create --------------------------------------------------------------

	/**
	 * Create User
	 *
	 * Takes a gmail address as an '_id' and a first and last name and
	 * creates a scitran user.
	 */
	create(req, res, next) {
		sanitize.req(req, models.newUser, (err, user) => {
			if (err) {return next(err);}
			c.blacklist.findOne({_id: user._id}).then((item) => {
				if (item) {
					let error = new Error("This user email has been blacklisted and cannot be given an account");
					error.http_code = 403;
					return next(error);
				} else {
					scitran.createUser(user, (err, resp) => {
						if (!err) {res.send(resp);}
					});
				}
			});
		});
	},
<commit_msg>Suppress error code on blacklisted user creation requests<commit_after>// dependencies ------------------------------------------------------------

import scitran  from '../libs/scitran';
import sanitize from '../libs/sanitize';
import mongo    from '../libs/mongo';

let c = mongo.collections;

// models ------------------------------------------------------------------

let models = {
	newUser: {
		_id:       'string, required',
		firstname: 'string, required',
		lastname:  'string, required'
	},
	blacklistUser: {
		_id:       'string, required',
		firstname: 'string',
		lastname:  'string',
		note:      'string'
	}
}

// handlers ----------------------------------------------------------------

/**
 * Users
 *
 * Handlers for user actions.
 */
export default {


	// create --------------------------------------------------------------

	/**
	 * Create User
	 *
	 * Takes a gmail address as an '_id' and a first and last name and
	 * creates a scitran user.
	 */
	create(req, res, next) {
		sanitize.req(req, models.newUser, (err, user) => {
			if (err) {return next(err);}
			c.blacklist.findOne({_id: user._id}).then((item) => {
				if (item) {
					res.send({status: 403, error: "This user email has been blacklisted and cannot be given an account"});
				} else {
					scitran.createUser(user, (err, resp) => {
						if (!err) {res.send(resp);}
					});
				}
			});
		});
	},

{'fraction_non_alphanumeric': 0.310752688172043, 'fraction_numerical': 0.002150537634408602, 'mean_word_length': 1.4830960854092528, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6297487', 'n_tokens_mistral': 916, 'n_tokens_neox': 809, 'n_words': 225}