<commit_before>

racts.service('authService', ['$http', '$q', function($http, $q){
	var credentials = {email: "", password: ""}
	this.credentials = function(){return credentials}

	var authenticate = function(defer){
		$http.post('/login', {credentials: credentials})
		.success(function(data){
			if(data.success === false){
				defer.reject()
			}
			else{
			defer.resolve(data.user)
			}
		})
		.error(function(){
			defer.reject()
		})
	}


	this.submit = function(){
		deferSubmit = $q.defer()
		authenticate(deferSubmit)
		return deferSubmit.promise
	}

}])

racts.controller('authController', ['$scope','currentUser', 'authService','localStorageCheck', function($scope, currentUser, authService, localStorageCheck){

console.log('Its authController speaking!')

	// execute localstorage checker inside currentuser
	// console.log(session.get())
	$scope.credentials = authService.credentials

	$scope.submit = function(){
		authService.submit().then( successfullAuth, errorAuth )
	}

	function successfullAuth(user){
		console.log('weeeee!!')
		console.log(currentUser)
		currentUser.user = user;

	}
	function errorAuth(){
		console.log('Authentication failed!')
	}


}])




racts.service('session', ['currentUser', function(currentUser){
	
	this.localStorageCheck = function(){
		console.log('foo. localstoragecheck is doing some work')

	}



	this.set = function(currentUser){
		window.localStorage['currentUser'] = JSON.stringify(currentUser)
	}

	this.get = function(){
		var localStorage = window.localStorage['currentUser']
		if ( localStorage ){
			return JSON.parse(localStorage)
		}
		else {
			return null
		}
	}

	

}])


racts.factory('currentUser', [function(){

	// this.checkLocalStorage = function(){



	var currentUser = null

	// var currentUser =  {
	// 	id: null,
	// 	email: null
	// }

	return currentUser
<commit_msg>getting updated version of whatever<commit_after>

racts.service('authService', ['$http', '$q', function($http, $q){
	var credentials = {email: "", password: ""}
	this.credentials = function(){return credentials}

	var authenticate = function(defer){
		$http.post('/login', {credentials: credentials})
		.success(function(data){
			if(data.success === false){
				defer.reject()
			}
			else{
			var currentUser = {email: credentials.email, id: data.user}
			defer.resolve(currentUser)
			}
		})
		.error(function(){
			defer.reject()
		})
	}


	this.submit = function(){
		deferSubmit = $q.defer()
		authenticate(deferSubmit)
		return deferSubmit.promise
	}

}])

racts.controller('authController', ['$scope','currentUser', 'authService','localStorageCheck', 'session', function($scope, currentUser, authService, localStorageCheck, session){


	console.log(session.currentUser)
	console.log(currentUser)
	setInterval(function(){console.log(currentUser,session.currentUser )},1000)


	$scope.credentials = authService.credentials
	$scope.submit = function(){
		authService.submit().then( successfullAuth, errorAuth )
	}

	function successfullAuth(user){
		console.log('weeeee!!')
		session.setCurrentUser(user)

	}
	function errorAuth(){
		console.log('Authentication failed!')
	}


}])




racts.service('session', ['$q', 'currentUser', function($q, currentUser){
	
	function getLocal(){
		var localStorage = window.localStorage['currentUser']
		if ( localStorage ){
			return JSON.parse(localStorage)
		}
		else {
			return null
		}
	}
	this.localStorageCheck = function(){
		console.log('im working in localstorage right now')
		var deferLocalCheck = $q.defer()
		user = getLocal()
		if (user){
			setCurrentUser(user)
			var trigger = true
		}
		deferLocalCheck.resolve(trigger)
		return deferLocalCheck.promise
	}



	function setLocal(currentUser){
		window.localStorage['currentUser'] = JSON.stringify(currentUser)
	}
	function setCurrentUser(user){
		console.log('inside setCurrentUser')
		console.log(user)
		currentUser = user
		setLocal(user)
	}
	this.setCurrentUser = setCurrentUser


	this.currentUser = currentUser


	

}])


racts.factory('currentUser', [function(){

	var currentUser = null

	return currentUser

{'fraction_non_alphanumeric': 0.14930129933807307, 'fraction_numerical': 0.000980632507967639, 'mean_word_length': 4.619834710743802, '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': '2995875', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1259, 'n_words': 243}