<commit_before>App.con = App.Controller = {
    
    initialize: function () {
        App.debug('App.Controller.initialize()');
        App.instance = this;
        // Set up error handling
        $( document ).ajaxError(App.Controller.onAjaxError);
        // Create models
        App.con.userModel = new App.UserModel();
        App.con.mediaSources = new App.MediaModel({parse:true});
        App.con.queryCollection = new App.QueryCollection();
        // Create view manager and app-level views
        App.con.vm = new App.ViewManager({
            "selector": '.content .container'
        });
        App.con.controlsView = new App.ControlsView({ userModel: App.con.userModel });
        App.con.toolView = new App.ToolListView({
            collection:App.con.queryCollection
        });
        $('.brand-toolbar .links').append(App.con.toolView.el);
        $('.controls').append(App.con.controlsView.el);
        App.con.router = new App.Router();
        // Bind event handlers
        _.bindAll(this, 'onSignIn');
        _.bindAll(this, 'onSignOut');
        // Listener for events
        App.con.queryCollection.resources.on('error', function (model_or_controller, request) {
            App.debug('Received error: ' + request.status);
            App.con.userModel.signOut();
        });
        App.con.userModel.on('signin', App.con.onSignIn);
        App.con.userModel.on('signout', App.con.onSignOut);
        App.con.userModel.on('unauthorized', App.con.onSignOut);
        // Start navigation and log user in
        App.con.userModel.signIn({
            "success": function(model, response) {
                _.defer(function () {
                    Backbone.history.start();
                });
            }
            , "error": function(model, response) {
                _.defer(function () {
                    App.debug('Error logging in');
                    console.log(response);
                    Backbone.history.start();
                    App.con.router.navigate('login', true);
                });<commit_msg>Only sign out on authentication errors, for #146.<commit_after>App.con = App.Controller = {
    
    initialize: function () {
        App.debug('App.Controller.initialize()');
        App.instance = this;
        // Set up error handling
        $( document ).ajaxError(App.Controller.onAjaxError);
        // Create models
        App.con.userModel = new App.UserModel();
        App.con.mediaSources = new App.MediaModel({parse:true});
        App.con.queryCollection = new App.QueryCollection();
        // Create view manager and app-level views
        App.con.vm = new App.ViewManager({
            "selector": '.content .container'
        });
        App.con.controlsView = new App.ControlsView({ userModel: App.con.userModel });
        App.con.toolView = new App.ToolListView({
            collection:App.con.queryCollection
        });
        $('.brand-toolbar .links').append(App.con.toolView.el);
        $('.controls').append(App.con.controlsView.el);
        App.con.router = new App.Router();
        // Bind event handlers
        _.bindAll(this, 'onSignIn');
        _.bindAll(this, 'onSignOut');
        // Listener for events
        App.con.queryCollection.resources.on('error', function (model_or_controller, request) {
            App.debug('Received error: ' + request.status);
            if (request.status == 401 || request.status == 403) {
                App.con.userModel.signOut();
            } else {
                var error = new Backbone.Model({
                    "message": request.responseText
                });
                App.con.getErrorCollection().add(error);
            }
        });
        App.con.userModel.on('signin', App.con.onSignIn);
        App.con.userModel.on('signout', App.con.onSignOut);
        App.con.userModel.on('unauthorized', App.con.onSignOut);
        // Start navigation and log user in
        App.con.userModel.signIn({
            "success": function(model, response) {
                _.defer(function () {
                    Backbone.history.start();
                });
            }
            , "error": function(model, response) {
                _.defer(function () {
                    App.debug('Error logging in');
                    console.log(response);
                    Backbone.history.start();
                    App.con.router.navigate('login', true);
                });
{'fraction_non_alphanumeric': 0.13831944131561164, 'fraction_numerical': 0.0020274836674926784, 'mean_word_length': 1.8136882129277567, 'pattern_counts': {'":': 7, '<': 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': '2535720', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1173, 'n_words': 216}