<commit_before>var app = angular.module('app', [
        'ngResource',
        'ngRoute'
        ]);


app.factory('csrfReset', ['$q', '$injector', '$browser', function($q, $injector, $browser) {
    var csrfReset = {};

    csrfReset.responseError = function(response) {
        // When the CSRF token fails, we get back a new one in a cookie, retry
        // the request with the new token.
        if (response.status == 400 && typeof response.data.errors.csrf !== null) {
            var $http = $injector.get('$http');
            var httpConfig = response.config;

            // Get the new xsrfValue from the cookies
            var xsrfValue = $browser.cookies()[$http.defaults.xsrfCookieName];

            if (xsrfValue) {
                httpConfig.headers[$http.defaults.xsrfHeaderName] = xsrfValue;
            }

            // Return the new request
            return $http(httpConfig);
        }

        return $q.reject(response);
    };

    return csrfReset;
}]);

app.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.xsrfHeaderName = 'X-CSRF-Token';
    $httpProvider.defaults.xsrfCookieName = 'CSRF-Token';
    $httpProvider.interceptors.push('csrfReset');
}]);

app.directive('serverError', function() {
    return {
        restrict: 'A',
        require: '?ngModel',
        link: function(scope, element, attrs, ctrl) {<commit_msg>Add some logging for the CSRF Reset<commit_after>var app = angular.module('app', [
        'ngResource',
        'ngRoute'
        ]);


app.factory('csrfReset', ['$q', '$injector', '$browser', '$log', function($q, $injector, $browser, $log) {
    var csrfReset = {};

    csrfReset.responseError = function(response) {
        // When the CSRF token fails, we get back a new one in a cookie, retry
        // the request with the new token.
        if (response.status == 400 && typeof response.data.errors.csrf !== null) {
            $log.debug('CSRF token was invalid, going to re-run request');
            var $http = $injector.get('$http');
            var httpConfig = response.config;

            // Get the new xsrfValue from the cookies
            var xsrfValue = $browser.cookies()[$http.defaults.xsrfCookieName];

            if (xsrfValue) {
                httpConfig.headers[$http.defaults.xsrfHeaderName] = xsrfValue;
            }

            // Return the new request
            return $http(httpConfig);
        }

        return $q.reject(response);
    };

    return csrfReset;
}]);

app.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.xsrfHeaderName = 'X-CSRF-Token';
    $httpProvider.defaults.xsrfCookieName = 'CSRF-Token';
    $httpProvider.interceptors.push('csrfReset');
}]);

app.directive('serverError', function() {
    return {
        restrict: 'A',
        require: '?ngModel',
        link: function(scope, element, attrs, ctrl) {
{'fraction_non_alphanumeric': 0.1408791969539633, 'fraction_numerical': 0.0020768431983385254, 'mean_word_length': 2.4693877551020407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5972504', 'n_tokens_mistral': 865, 'n_tokens_neox': 848, 'n_words': 200}