(function() {
	'use strict';

	app.controller('Login', [
		'$scope',
		'account.repository',
		'$location',
		'$uibModalInstance',
		function($scope, accountRepository, $location, $uibModalInstance) {
			$scope.user = {
				"login": "",
				"password": ""
			};

			$scope.submitLogin = function() { 
				accountRepository.login($scope.user).then(function(response) {
					console.log(response);
					$location.path($location.url());
					localStorage.setItem('authToken', response.data.authToken);
					$uibModalInstance.close(true);
				}, function(error) {});
			}
		}]);
})();