<commit_before>/*
Name: DB Handler
Project: Maelström - Users
Author: demiurgosoft <<EMAIL>>
Description: Mongoose database handler
*/


var User = require('./models/user');


//Calls done with boolean value if user with username or email exists
function isUser(username, email, done) {
	Handler.findUser(username, function(err, res) {
		if (res) done(err, true);
		else {
			Handler.findUser(email, function(err, res) {
				if (res) done(err, true);
				else done(err, false);
			});
		}
	});
}

var Handler = {
	//Find user given username/email
	findUser: function(username, done) {
		if (!username) return done(new Error("Not username or email provided"));
		User.findOne({
			$or: [{
				"username": username
			}, {
				"email": username
			}]
		}, done);
	},
	findById: function(userId, done) {
		if (!userId) return done(new Error("Not id provided"));
		else User.findOne({<commit_msg>bug fixed: users can be found ignoring case<commit_after>/*
Name: DB Handler
Project: Maelström - Users
Author: demiurgosoft <<EMAIL>>
Description: Mongoose database handler
*/


var User = require('./models/user');


//Calls done with boolean value if user with username or email exists
function isUser(username, email, done) {
	Handler.findUser(username, function(err, res) {
		if (res) done(err, true);
		else {
			Handler.findUser(email, function(err, res) {
				if (res) done(err, true);
				else done(err, false);
			});
		}
	});
}

var Handler = {
	//Find user given username/email
	findUser: function(username, done) {
		if (!username) return done(new Error("Not username or email provided"));
		User.findOne({
			$or: [{
				"username": new RegExp("^" + username, "i")
			}, {
				"email": username
			}]
		}, done);
	},
	findById: function(userId, done) {
		if (!userId) return done(new Error("Not id provided"));
		else User.findOne({
{'fraction_non_alphanumeric': 0.1502449646162221, 'fraction_numerical': 0.0, 'mean_word_length': 3.914438502673797, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, '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': '4017269', 'n_tokens_mistral': 656, 'n_tokens_neox': 589, 'n_words': 185}