<commit_before>﻿var app = angular.module('app', ['ui.router', 'ui.bootstrap', 'ui.select2', 'ngAnimate', 'notify', 'xeditable', 'restangular', 'ui.utils', 'angularjs-dropdown-multiselect']);

app.config(['$urlRouterProvider', function ($urlRouterProvider) {
    $urlRouterProvider.otherwise('/');
}]);

app.config(['$httpProvider', 'notifyProvider', 'RestangularProvider', function ($httpProvider, notifyProvider, restangularProvider) {
    $httpProvider.interceptors.push("httpBusyInterceptor");

    notifyProvider.globalTimeToLive(5000);
    notifyProvider.onlyUniqueMessages(false);

    //Restangular config
    restangularProvider.setBaseUrl('/api');
    restangularProvider.setRestangularFields({
        id: 'id'
    });
    restangularProvider.setResponseExtractor(function (response, operation) {
        return response.response;
    });
}]);

app.run(['$rootScope', '$http', '$state', 'editableOptions', '$modal', 'notify', 'userService', 'uiSelect2Config',
    function ($rootScope, $http, $state, editableOptions, $modal, notify, userService, uiSelect2Config) {
        //init info
        $rootScope.page = {
            title: 'Index',
            subnav: []
        };

        uiSelect2Config.dropdownAutoWidth = true;

        //x-editable config
        editableOptions.theme = 'bs3'; // bootstrap3 theme.

        //logout function for top navigation bar
        $rootScope.logout = function () {
            userService.logout().then(function () {
                $state.go('index');
            });

        };

        //when changing states, we might need to authorize the user
        $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {

            if (toState.noAuth) return; //no need to auth
            
            userService.auth(toState.adminRoles).then(function (val) {
                //Authentication OK!
                
            }, function () {
                event.preventDefault();

                //Bad authentication
                $state.go('index', { to: toState.name, toParams: toParams });<commit_msg>added auth check in app run<commit_after>﻿var app = angular.module('app', ['ui.router', 'ui.bootstrap', 'ui.select2', 'ngAnimate', 'notify', 'xeditable', 'restangular', 'ui.utils', 'angularjs-dropdown-multiselect']);

app.config(['$urlRouterProvider', function ($urlRouterProvider) {
    $urlRouterProvider.otherwise('/');
}]);

app.config(['$httpProvider', 'notifyProvider', 'RestangularProvider', function ($httpProvider, notifyProvider, restangularProvider) {
    $httpProvider.interceptors.push("httpBusyInterceptor");

    notifyProvider.globalTimeToLive(5000);
    notifyProvider.onlyUniqueMessages(false);

    //Restangular config
    restangularProvider.setBaseUrl('/api');
    restangularProvider.setRestangularFields({
        id: 'id'
    });
    restangularProvider.setResponseExtractor(function (response, operation) {
        return response.response;
    });
}]);

app.run(['$rootScope', '$http', '$state', 'editableOptions', '$modal', 'notify', 'userService', 'uiSelect2Config',
    function ($rootScope, $http, $state, editableOptions, $modal, notify, userService, uiSelect2Config) {
        //init info
        $rootScope.page = {
            title: 'Index',
            subnav: []
        };

        //this will try to authenticate - to see if the user's already logged in
        userService.getUser();

        uiSelect2Config.dropdownAutoWidth = true;

        //x-editable config
        editableOptions.theme = 'bs3'; // bootstrap3 theme.

        //logout function for top navigation bar
        $rootScope.logout = function () {
            userService.logout().then(function () {
                $state.go('index');
            });

        };

        //when changing states, we might need to authorize the user
        $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {

            if (toState.noAuth) return; //no need to auth
            
            userService.auth(toState.adminRoles).then(function (val) {
                //Authentication OK!
                
            }, function () {
                event.preventDefault();

                //Bad authentication
                $state.go('index', { to: toState.name, toParams: toParams });
{'fraction_non_alphanumeric': 0.14044814044814044, 'fraction_numerical': 0.00462000462000462, 'mean_word_length': 2.765217391304348, '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': '3277153', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1148, 'n_words': 249}