<commit_before>
define([
	'marionette',
	'marionette.formview',
	'text!template/login.html'
], function(Marionette, MarionetteFormView, LoginTemplate)
{
	var LoginView = Marionette.FormView.extend(
	{
		template: LoginTemplate,

		/**
		 * Declare inputs that should be validate
		 */
		fields: {
			email: {
				el: '#login-email',
				required: "Please enter a valid Email Address.",
				validations: {
					email: "Please enter a valid Email Address."
				}
			}
		},

		/**
		 * Submit authentication request
		 */
		onSubmit: function (evt)
		{
			evt.preventDefault();

			var url = 'api/v1/auth';

			var formValues = {
				'email': $('#login-email').val(),
				'password': <PASSWORD>').<PASSWORD>()
			};

			$.ajax(
			{
				url: url,
				type: 'POST',
				dataType: 'json',
				data: formValues,
				success: function (data)
				{
					console.log(['Login request details: ', data]);
					Backbone.history.navigate('/#');
				},
				error: function (xhr, status)
				{
					showGlobalError('Error');
				}
			});
		},

		/**
		 * What to do if the submit fails
		 */
		onSubmitFail: function (errors)
		{
			
		},

		/**
		 * Show an error
		 */
		showGlobalError: function (message)
		{
			var container = $('#login-alert-container');
			var alertbox = $('<div class="alert alert-error" />')<commit_msg>login view will trigger login success event which will be catch by account router<commit_after>
define([
	'marionette',
	'marionette.formview',
	'text!template/login.html'
], function(Marionette, MarionetteFormView, LoginTemplate)
{
	var LoginView = Marionette.FormView.extend(
	{
		template: LoginTemplate,

		/**
		 * Submit authentication request
		 */
		onSubmit: function (evt)
		{
			evt.preventDefault();

			// This store this object
			var me = this;

			// Get application
			var App = this.options.app;

			// Do the request to log the user
			$.ajax(
			{
				url: 'api/v1/auth',
				type: 'POST',
				dataType: 'json',
				data: {
					'email': $('#login-email').val(),
					'password': <PASSWORD>').val()
				},
				success: function (response)
				{
					App.vent.trigger('login:success', response.data);
				},
				error: function (xhr, status)
				{
					me.showGlobalError('Unable to authenticate');
				}
			});
		},

		/**
		 * Show an error
		 */
		showGlobalError: function (message)
		{
			var container = $('#login-alert-container');
			var alertbox = $('<div class="alert alert-error" />')
{'fraction_non_alphanumeric': 0.15774299835255354, 'fraction_numerical': 0.0008237232289950577, 'mean_word_length': 2.7717391304347827, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '6251658', 'n_tokens_mistral': 995, 'n_tokens_neox': 776, 'n_words': 190}