<commit_before>var mongo = require("./mongo");
var mongoURL = 'mongodb://localhost:27017/binaryGame';
var mongoDbHelper = require('./mongo-db-helper');
var mongodb = require('mongodb');


exports.login = function(request,response){	
	var email = request.body.email;
	var passord = request.body.password;
	mongo.connect(mongoURL, function() {
		var userDetails = mongo.collection('userDetails');
		mongoDbHelper.readOne(userDetails,{'email':email},null, function(data) {
				if(data==undefined){
					response.send({"Status":500,
						"Message": "No user Exists"});
					}else{
						var getPassword = data.password;
						if(passord===getPassword){
							response.send({
								"Status":200,
								"Message":"Validation Successfull"
							});
						}else{
							response.send({
								"Status":401,
								"Message":"Unauthorized"
							});
						}
					}
			});
		});
};

exports.register = function(request,response){
	var user = {};
	user.fname = request.body.fname;
	user.lname = request.body.lname;
	user.email = request.body.email;
	user.password = request.body.password;
	user.school = request.body.school;
	mongo.connect(mongoURL, function() {
	var userDetails = mongo.collection('userDetails');
	mongoDbHelper.insertIntoCollection(userDetails, user, function() {
		mongodb.MongoClient.connect('mongodb://localhost:27017/binaryGame', function(error, db) {		
			if(error){
				response.send({"Status":500,
					"Message": "Unable to Register"});
				}else{
					response.send({"Status":200,
						"message":"Registration Successfull"});
				}
		});
	});
	});
};<commit_msg>Adding if user exists check in register<commit_after>var mongo = require("./mongo");
var mongoURL = 'mongodb://localhost:27017/binaryGame';
var mongoDbHelper = require('./mongo-db-helper');
var mongodb = require('mongodb');


exports.login = function(request,response){	
	var email = request.body.email;
	var passord = request.body.password;
	mongo.connect(mongoURL, function() {
		var userDetails = mongo.collection('userDetails');
		mongoDbHelper.readOne(userDetails,{'email':email},null, function(data) {
				if(data==undefined){
					response.send({"Status":500,
						"Message": "No user Exists"});
					}else{
						var getPassword = data.password;
						if(passord===getPassword){
							response.send({
								"Status":200,
								"Message":"Validation Successfull"
							});
						}else{
							response.send({
								"Status":401,
								"Message":"Unauthorized"
							});
						}
					}
			});
		});
};

exports.register = function(request,response){
	var user = {};
	user.fname = request.body.fname;
	user.lname = request.body.lname;
	user.email = request.body.email;
	user.password = <PASSWORD>;
	user.school = request.body.school;
	mongo.connect(mongoURL, function() {
	var userDetails = mongo.collection('userDetails');
	mongoDbHelper.readOne(userDetails,{'email':user.email},null,function(data){
		if(data==undefined){//}
			mongoDbHelper.insertIntoCollection(userDetails, user, function() {
			mongodb.MongoClient.connect('mongodb://localhost:27017/binaryGame', function(error, db) {
					
					if(error){
						response.send({"Status":500,
							"Message": "Unable to Register"});
						}else{
							response.send({"Status":200,
								"message":"Registration Successfull"});
						}
				});
			});
			}//if condition end
		else
		{ 
			response.send({Status:500,"Message":"User already registered with this email, Try another email!"})
		}
	});
	});
};
{'fraction_non_alphanumeric': 0.1659942363112392, 'fraction_numerical': 0.01527377521613833, 'mean_word_length': 3.6778975741239894, 'pattern_counts': {'":': 21, '<': 4, '<?xml version=': 0, '>': 4, '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': '4592313', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1082, 'n_words': 183}