<commit_before>angular.module( 'orderCloud' )

	.config( LoginConfig )
	.factory( 'LoginService', LoginService )
	.controller( 'LoginCtrl', LoginController )

;

function LoginConfig( $stateProvider ) {
	$stateProvider.state( 'login', {
		url: '/login/:token',
		templateUrl:'login/templates/login.tpl.html',
		controller:'LoginCtrl',
		controllerAs: 'login',
		data:{
			limitAccess: false //Whether or not to require authentication on this state
		}
	});
}

function LoginService( $q, PasswordResets, clientid ) {
	var service = {
		SendVerificationCode: _sendVerificationCode,
		ResetPassword: <PASSWORD>
	};

	function _sendVerificationCode(email) {
		var deferred = $q.defer();

		var passwordResetRequest = {
			Email: email,
			ClientID: clientid,
			URL: encodeURIComponent($window.location.href) + '{0}'
		};

		PasswordResets.SendVerificationCode(passwordResetRequest)
			.then(function() {
				deferred.resolve();
			})
			.catch(function(ex) {
				deferred.reject(ex);
			});

		return deferred.promise;
	}

	function _resetPassword(resetPasswordCredentials, verificationCode) {
		var deferred = $q.defer();

		var passwordReset = {
			ClientID: clientid,
			Username: resetPasswordCredentials.ResetUsername,
			Password: <PASSWORD>
		};

		PasswordResets.ResetPassword(verificationCode, passwordReset).
			then(function() {
				deferred.resolve();
			})
			.catch(function(ex) {
				deferred.reject(ex);
			});

		return deferred.promise;
	}

	return service;
}

function LoginController( $state, $stateParams, $exceptionHandler, LoginService, Credentials ) {
	var vm = this;

	vm.token = $stateParams.token;
	vm.form = vm.token ? 'reset' : 'login';
	vm.setForm = function(form) {
		vm.form = form;
	};

	vm.submit = function( ) {
		Credentials.Get( vm.cffredentials ).then(
			function() {
				$state.go( 'base.home' );
			});
	};

	vm.forgotPassword = function() {
		LoginService.SendVerificationCode(vm.credentials.Email)
			.then(function() {
				vm.setForm('verificationCodeSuccess');
				vm.credentials.Email = null;
			})
			.catch(function(ex) {
				$exceptionHandler(ex);
			});
	};

	vm.resetPassword = function() {
		LoginService.ResetPassword(vm.credentials, vm.token)
			.then(function() {
				vm.setForm('resetSuccess');
				vm.token = null;
				vm.credentials.ResetUsername = null;<commit_msg>Steve, do you WANT my shoe!?<commit_after>angular.module( 'orderCloud' )

	.config( LoginConfig )
	.factory( 'LoginService', LoginService )
	.controller( 'LoginCtrl', LoginController )

;

function LoginConfig( $stateProvider ) {
	$stateProvider.state( 'login', {
		url: '/login/:token',
		templateUrl:'login/templates/login.tpl.html',
		controller:'LoginCtrl',
		controllerAs: 'login',
		data:{
			limitAccess: false //Whether or not to require authentication on this state
		}
	});
}

function LoginService( $q, PasswordResets, clientid ) {
	var service = {
		SendVerificationCode: _sendVerificationCode,
		ResetPassword: _<PASSWORD>
	};

	function _sendVerificationCode(email) {
		var deferred = $q.defer();

		var passwordResetRequest = {
			Email: email,
			ClientID: clientid,
			URL: encodeURIComponent($window.location.href) + '{0}'
		};

		PasswordResets.SendVerificationCode(passwordResetRequest)
			.then(function() {
				deferred.resolve();
			})
			.catch(function(ex) {
				deferred.reject(ex);
			});

		return deferred.promise;
	}

	function _resetPassword(resetPasswordCredentials, verificationCode) {
		var deferred = $q.defer();

		var passwordReset = {
			ClientID: clientid,
			Username: resetPasswordCredentials.ResetUsername,
			Password: <PASSWORD>
		};

		PasswordResets.ResetPassword(verificationCode, passwordReset).
			then(function() {
				deferred.resolve();
			})
			.catch(function(ex) {
				deferred.reject(ex);
			});

		return deferred.promise;
	}

	return service;
}

function LoginController( $state, $stateParams, $exceptionHandler, LoginService, Credentials ) {
	var vm = this;

	vm.token = $stateParams.token;
	vm.form = vm.token ? 'reset' : 'login';
	vm.setForm = function(form) {
		vm.form = form;
	};

	vm.submit = function() {
		Credentials.Get( vm.credentials ).then(
			function() {
				$state.go( 'base.home' );
			});
	};

	vm.forgotPassword = function() {
		LoginService.SendVerificationCode(vm.credentials.Email)
			.then(function() {
				vm.setForm('verificationCodeSuccess');
				vm.credentials.Email = null;
			})
			.catch(function(ex) {
				$exceptionHandler(ex);
			});
	};

	vm.resetPassword = function() {
		LoginService.ResetPassword(vm.credentials, vm.token)
			.then(function() {
				vm.setForm('resetSuccess');
				vm.token = null;
				vm.credentials.ResetUsername = null;
{'fraction_non_alphanumeric': 0.14156820622986035, 'fraction_numerical': 0.0004296455424274973, 'mean_word_length': 4.055374592833876, 'pattern_counts': {'":': 0, '<': 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': '4001328', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1497, 'n_words': 276}