<commit_before>'use strict';

angular.module('anyfetchFrontApp.services', [])
.factory( 'AuthService', function($cookies, $cookieStore, $http) {
	var currentUser;

	var login = function() {
		var credentials = $cookies.credentials;
		if (!credentials) {
			document.location.href = '/login.html';
		}

		$http.defaults.headers.common.Authorization = 'Basic ' + credentials;
		$http({method: 'GET', url: 'http://api.anyfetch.com'})
			.success(function(data, status) {
				if (status !== 200) {
					console.log('Error ', data);
				}
				data.credentials = credentials;
				currentUser = data;
			})
			.error(function(data) {
				console.log('Error ', data);
			});
	};

	var logout = function(cb) {
		$cookieStore.remove('credentials');
		cb();
	};

	var isLoggedin = function() { return currentUser ? true : false; };

	var getUser = function() { return currentUser; };

	return {
		login: login,
		logout: logout,
		isLoggedin : isLoggedin,
		currentUser: getUser
	};
});<commit_msg>Add service for providers<commit_after>'use strict';

angular.module('anyfetchFrontApp.services', [])
.factory( 'AuthService', function($cookies, $cookieStore, $http) {
	var currentUser;

	var login = function() {
		var credentials = $cookies.credentials;
		if (!credentials) {
			document.location.href = '/login.html';
		}

		$http.defaults.headers.common.Authorization = 'Basic ' + credentials;
		$http({method: 'GET', url: 'http://api.anyfetch.com'})
			.success(function(data, status) {
				if (status !== 200) {
					console.log('Error ', data);
				}
				data.credentials = credentials;
				currentUser = data;
			})
			.error(function(data) {
				console.log('Error ', data);
			});
	};

	var logout = function(cb) {
		$cookieStore.remove('credentials');
		cb();
	};

	var isLoggedin = function() { return currentUser ? true : false; };

	var getUser = function() { return currentUser; };

	return {
		login: login,
		logout: logout,
		isLoggedin : isLoggedin,
		currentUser: getUser
	};
})
.factory( 'ProviderService', function($http, AuthService) {
	var connectedProviders;

	var setProviders = function(providers, cb) {
		connectedProviders = providers;
		cb();
	};

	var updateConnectedProviders = function(cb) {
		$http.defaults.headers.common.Authorization = 'Basic ' + AuthService.getUser().credentials;
		$http({method: 'GET', url: 'http://api.anyfetch.com/update'})
			.success(function(data, status) {
				if (status !== 204) {
					return cb(data);
				}
				cb(null);
			})
			.error(function(data) {
				cb(data);
			});
	};

	return {
		setProviders: setProviders,
		updateConnectedProviders: updateConnectedProviders
	};
});
{'fraction_non_alphanumeric': 0.16438876233864844, 'fraction_numerical': 0.003416856492027335, 'mean_word_length': 3.8796296296296298, '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': '4190864', 'n_tokens_mistral': 996, 'n_tokens_neox': 864, 'n_words': 175}