'use strict';
$('form[name="login"]').submit(function(e) {
	e.preventDefault();
	var formData = $('form[name="login"]').serializeArray().reduce(function(obj, item) {
	    obj[item.name] = item.value;
	    return obj;
	}, {});

	request({
	  	url: "/sven/api/auth",
	  	data: {
			"type": "login",
	  		"user": formData.loginUser,
	  		"pass": formData.loginPass,
			"csrf": formData.csrf_token
		}
  	}, function(data) {
		console.log(data.status, data);
		document.location = "./";
	}, function(data) {
		console.log(data.status, data.responseJSON);
	});
});
