<commit_before>/******************************************
* APPLICATION NAMESPACE
*/
define('main', [

	// Load our app module and pass it to our definition function
	'app', 'appRouter', 'moment', 'usersCollection', 'userModel'

], function(app, AppRouter, moment, UsersCollection, UserModel){

	'use strict';

	var main  = {


		/** Application initialization
		*/
		init: function(lang) {

		// Retrieve App properties, configuration and language //
		$.when(app.loadStaticFile('properties.json'),
			   app.loadStaticFile('config/configuration.json'),
			   app.loadStaticFile('config/routes.json'),
			   app.loadStaticFile('i18n/'+lang+'/app-lang.json'))
			.done(function (properties_data, configuration_data, routes_data, lang_data) {


				// Set the app properties configuration and language //
				app.properties  = properties_data[0];
				app.config 		= configuration_data[0];
				app.routes      = routes_data[0];
				app.lang        = lang_data[0];
				app.config.lang = lang;

				// Shortcup to the menus //
				app.menus = app.config.menus;
			

				moment.lang(app.config.lang);

                // Interface to current_user, this should not be a collection stored in localstorage but just some current_user client state.
                app.current_user = new UserModel(JSON.parse(localStorage.getItem('current_user')));  //app.current_user

				// Set the Ajax Setup //
				app.setAjaxSetup();


				// Router initialization //
				app.router = new AppRouter();


				// Listen url changes //
				Backbone.history.start({pushState: false});
			})
			.fail(function(){
				console.error('Unable to init the app');
			});
		}

}


return main;


});<commit_msg>fixes #2114 Remove session informations from localstorage when 401 error<commit_after>/******************************************
 * APPLICATION NAMESPACE
 */
define('main', [

    // Load our app module and pass it to our definition function
    'app', 'appRouter', 'moment', 'usersCollection', 'userModel'

], function (app, AppRouter, moment, UsersCollection, UserModel) {

    'use strict';

    var main = {


        /** Application initialization
         */
        init: function (lang) {

            // Retrieve App properties, configuration and language //
            $.when(app.loadStaticFile('properties.json'),
                    app.loadStaticFile('config/configuration.json'),
                    app.loadStaticFile('config/routes.json'),
                    app.loadStaticFile('i18n/' + lang + '/app-lang.json'))
                .done(function (properties_data, configuration_data, routes_data, lang_data) {


                    // Set the app properties configuration and language //
                    app.properties = properties_data[0];
                    app.config = configuration_data[0];
                    app.routes = routes_data[0];
                    app.lang = lang_data[0];
                    app.config.lang = lang;

                    // Shortcup to the menus //
                    app.menus = app.config.menus;


                    moment.lang(app.config.lang);

                    // Interface to current_user, this should not be a collection stored in localstorage but just some current_user client state.
                    app.current_user = new UserModel(JSON.parse(localStorage.getItem('current_user')));  //app.current_user

                    // Set the Ajax Setup //
                    app.setAjaxSetup();


                    // Router initialization //
                    app.router = new AppRouter();


                    // Listen url changes //
                    Backbone.history.start({pushState: false});
                })
                .fail(function () {
                    console.error('Unable to init the app');
                });

            $(function () {
                $.ajaxSetup({
                    error: function (x, status, error) {
                        // If token expires , clear the localstorage to remove session
                        if (x.status == 401) {
                            localStorage.clear();
                        }

                    }
                });
            });

        }



    }


    return main;


});
{'fraction_non_alphanumeric': 0.13199052132701422, 'fraction_numerical': 0.005213270142180095, 'mean_word_length': 1.8481781376518218, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5339126', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1039, 'n_words': 267}