/* Setup Layout Part - Header */
CFPApp.controller('LoginController', ['$scope', '$rootScope', '$http', '$window', function ($scope, $rootScope, $http, $window) {
        $scope.data = {
            '_remember_me': false
        };
        $scope.errorMessage = null;

        /**
         * Submits the login form
         */
        $scope.submit = function () {
            $http.post(Routing.generate('admin_core_user_login_check', {_locale: Translator.locale}), $.param($scope.data), {
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            }).then(function (response) {
                $scope.errorMessage = null;
                $window.location.href = Routing.generate('admin_core_common_index', {_locale: Translator.locale});
            }, function (response) {
                if (400 === response.status || 403 === response.status) {
                    $scope.errorMessage = response.data.message;
                }
            });
        };
    }]);