<commit_before>(function() {
    'use strict';

    angular
        .module('app')
        .controller('ApplicationController', ApplicationController);

    ApplicationController.$inject = ['$state', '$rootScope', 'CredentialService'];
    function ApplicationController($state, $rootScope, CredentialService) {
        var vm = this;

        activate();

        function activate() {
            if (!CredentialService.isTokenPresent()) {
                $state.go('main.login');
            }
            else {
                $state.go('main.step1');
            }
        }

        function preventAndGo(stateName, event) {
            event.preventDefault();
            $state.go(stateName);
        }

        function checkProtectedRoutes(toState, event) {
            if (toState.data.protected) {
                if (!CredentialService.isTokenPresent()) {
                    preventAndGo('main.login', event);
                }
            }
        }

        function checkSpecificRoutes(toState, event) {
            if (toState.name === 'main.login' && CredentialService.isTokenPresent()) {
                preventAndGo('main.step1', event);
            }

            if (toState.name === 'main') {
                preventAndGo('main.step1', event);
            }
        }

        function checkCallbackRoute(toState, toParams, event) {
            if (toState.name === 'callback') {
                var redirectFlag = false;

                if (CredentialService.isTokenPresent()) {
                    redirectFlag = true;
                }
                else if (toParams.code === undefined || toParams.state === undefined) {
                    redirectFlag = true;
                }
                else if (!CredentialService.isStatePresent()) {
                    redirectFlag = true;
                }
                else if (toParams.state !== CredentialService.getState()) {
                    redirectFlag = true;
                }

                if (redirectFlag) {
                    preventAndGo('main.step1', event);
                }
            }
        }

        $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
            checkProtectedRoutes(toState, event);
            checkSpecificRoutes(toState, event);
            checkCallbackRoute(toState, toParams, event);
        });

        $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
            $rootScope.pageTitle = toState.data.title;
        });
    }
})();<commit_msg>Adjusted callback routing<commit_after>(function () {
    'use strict';

    angular
        .module('app')
        .controller('ApplicationController', ApplicationController);

    ApplicationController.$inject = ['$state', '$rootScope', 'CredentialService'];
    function ApplicationController($state, $rootScope, CredentialService) {
        var vm = this;

        activate();

        function activate() {
            if (!CredentialService.isTokenPresent()) {
                $state.go('main.login');
            }
            else {
                $state.go('main.step1');
            }
        }

        function preventAndGo(stateName, event) {
            event.preventDefault();
            $state.go(stateName);
        }

        function checkProtectedRoutes(toState, event) {
            if (toState.data.protected) {
                if (!CredentialService.isTokenPresent()) {
                    preventAndGo('main.login', event);
                }
            }
        }

        function checkSpecificRoutes(toState, event) {
            if (toState.name === 'main.login' && CredentialService.isTokenPresent()) {
                preventAndGo('main.step1', event);
            }

            if (toState.name === 'main') {
                preventAndGo('main.step1', event);
            }
        }

        function checkCallbackRoute(toState, toParams, event) {
            if (toState.name === 'main.callback') {
                var redirectFlag = false;

                if (CredentialService.isTokenPresent()) {
                    redirectFlag = true;
                }
                else if (toParams.code === undefined || toParams.state === undefined) {
                    redirectFlag = true;
                }
                else if (!CredentialService.isStatePresent()) {
                    redirectFlag = true;
                }
                else if (toParams.state !== CredentialService.getState()) {
                    redirectFlag = true;
                }

                if (redirectFlag) {
                    preventAndGo('main.step1', event);
                }
            }
        }

        $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
            checkProtectedRoutes(toState, event);
            checkSpecificRoutes(toState, event);
            checkCallbackRoute(toState, toParams, event);
        });

        $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
            $rootScope.pageTitle = toState.data.title;
        });
    }
})();
{'fraction_non_alphanumeric': 0.11736272235112143, 'fraction_numerical': 0.0015467904098994587, 'mean_word_length': 1.6113074204946995, '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': '6297836', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1245, 'n_words': 228}