<commit_before>/* global angular */


var app = angular.module(
    'scool',
    [
        'ngResource',
        'ngCookies',
        'ui.router',
        'ui.bootstrap',
        'ui.select2'
    ]
);


app.controller('IndexCtrl', function ($scope, $log, $rootScope, $location, $state, AUTH_EVENTS, Auth) {
    'use strict';



    $scope.go = function (path) {
        $location.path(path);
    };

    console.log('IndexCtrl');

    $rootScope.$on('unauthorized', function () {
        $state.go('public.login');
    });

    $rootScope.$on('loginFailure', function () {
        console.error('Login failed');
    });

    $rootScope.$on('loginSuccess', function () {
        $state.go('user.home');
    });

    $rootScope.$on('logoutSuccess', function () {
        $state.go('public.login');
    });


    $scope.logout = function () {
        $log.info('Logging out');

        Auth.logout();
    };

    $scope.current_user = Auth.getCurrentUser();
    if ($scope.current_user === undefined) {
        var x = $state.go('public.login').then(function () { console.log('good'); }, function (x) {console.log(x)});
    }

    console.log($scope.current_user);
    $rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
        console.log(toState);
        console.log(toParams);

        console.log('$stateChangeStart to '+toState.to+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
    });
     $rootScope.$on('$stateChangeError',
    function (event, toState, toParams, fromState, fromParams, error) {
        $log.debug(error);
        $state.go('login');
    });


});


app.controller('ErrorCtrl', function () {
});
<commit_msg>Code cleanup. Unauthorized login redirection is still WIP<commit_after>/* global angular */


var app = angular.module(
    'scool',
    [
        'ngResource',
        'ngCookies',
        'ui.router',
        'ui.bootstrap',
        'ui.select2'
    ]
);


app.controller('IndexCtrl', function ($scope, $log, $rootScope, $location, $state, AUTH_EVENTS, Auth) {
    'use strict';



    $scope.go = function (path) {
        $location.path(path);
    };

    console.log('IndexCtrl');

    $rootScope.$on('unauthorized', function () {
        $state.go('public.login');
    });

    $rootScope.$on('loginFailure', function () {
        console.error('Login failed');
    });

    $rootScope.$on('loginSuccess', function () {
        $state.go('user.home');
    });

    $rootScope.$on('logoutSuccess', function () {
        $state.go('public.login');
    });


    $scope.logout = function () {
        $log.info('Logging out');

        Auth.logout();
    };

    $scope.current_user = Auth.getCurrentUser();
    if ($scope.current_user === undefined) {
        $state.go('public.login');  // TODO: This fails :(
    }

});


app.controller('ErrorCtrl', function () {
});

{'fraction_non_alphanumeric': 0.17855957517424495, 'fraction_numerical': 0.0006637902422834385, 'mean_word_length': 2.2903930131004366, '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': '1402653', 'n_tokens_mistral': 974, 'n_tokens_neox': 900, 'n_words': 153}