<commit_before>'use strict';

var app = angular.module('SGTravelBuddy', [
    'ngRoute',
    'mobile-angular-ui',
    'SGTravelBuddy.translator',
    'SGTravelBuddy.auth'
]);

app.config(['$routeProvider', '$locationProvider', '$httpProvider', function ($routeProvider, $locationProvider, $httpProvider) {

    var access = authConfig.accessLevels;

    $routeProvider.when('/',
        {
            templateUrl: 'home.html',
            controller: 'MainCtrl',
            access: access.guest
        });
    $routeProvider.when('/login',
        {
            templateUrl: 'login.html',
            controller: 'LoginCtrl',
            access: access.guest
        });
    $routeProvider.when('/register',
        {
            templateUrl: 'register.html',
            controller: 'RegisterCtrl',
            access: access.guest
        });
    $routeProvider.when('/settings',
        {
            templateUrl: 'settings.html',
            controller: 'RegisterCtrl',
            access: access.public
        });
    $routeProvider.when('/private',
        {
            templateUrl: 'private.html',
            controller: 'MainController',
            access: access.user
        });
    $routeProvider.when('/404',
        {
            templateUrl: '404.html',
            access: access.public
        });
    $routeProvider.otherwise({redirectTo: '/404'});

    //$locationProvider.html5Mode(true);  todo enable this

    $httpProvider.interceptors.push(function ($q, $location) {
        return {
            'responseError': function (response) {
                if (response.status === 401 || response.status === 403) {
                    $location.path('/login');
                    return $q.reject(response);
                }
                else {
                    return $q.reject(response);
                }
            }
        }
    });

}]);

app.run(['$rootScope', '$location', 'Authorizer', function ($rootScope, $location, Authorizer) {

    $rootScope.$on("$routeChangeStart", function (event, next, current) {
        $rootScope.error = null;
        if (!Authorizer.authorize(next.access)) {
            if (Authorizer.isLoggedIn()) $location.path('/');
            else $location.path('/login');
        }
    });

}]);

<commit_msg>Fixed the issue with landing to login instead of home<commit_after>'use strict';

var app = angular.module('SGTravelBuddy', [
    'ngRoute',
    'mobile-angular-ui',
    'SGTravelBuddy.translator',
    'SGTravelBuddy.auth'
]);

app.config(['$routeProvider', '$locationProvider', '$httpProvider', function ($routeProvider, $locationProvider, $httpProvider) {

    var access = authConfig.accessLevels;

    $routeProvider.when('/',
        {
            templateUrl: 'home.html',
            controller: 'MainCtrl',
            access: access.guest
        });
    $routeProvider.when('/login',
        {
            templateUrl: 'login.html',
            controller: 'LoginCtrl',
            access: access.guest
        });
    $routeProvider.when('/register',
        {
            templateUrl: 'register.html',
            controller: 'RegisterCtrl',
            access: access.guest
        });
    $routeProvider.when('/settings',
        {
            templateUrl: 'settings.html',
            controller: 'RegisterCtrl',
            access: access.public
        });
    $routeProvider.when('/private',
        {
            templateUrl: 'private.html',
            controller: 'MainController',
            access: access.user
        });
    $routeProvider.when('/404',
        {
            templateUrl: '404.html',
            access: access.public
        });
    $routeProvider.otherwise({redirectTo: '/404'});

    //$locationProvider.html5Mode(true); // todo enable this

    $httpProvider.interceptors.push(function ($q, $location) {
        return {
            'responseError': function (response) {
                if (response.status === 401 || response.status === 403) {
                    $location.path('/login');
                    return $q.reject(response);
                }
                else {
                    return $q.reject(response);
                }
            }
        }
    });

}]);

app.run(['$rootScope', '$location', 'Authorizer', function ($rootScope, $location, Authorizer) {

    $rootScope.$on("$routeChangeStart", function (event, next, current) {
        if (next && next.$$route.originalPath === ""
            && next.$$route.redirectTo && next.$$route.redirectTo === "/") {
            $location.path('/');
        } else if (!Authorizer.authorize(next.access)) {
            if (Authorizer.isLoggedIn()) $location.path('/');
            else $location.path('/login');
        }
    });

}]);


{'fraction_non_alphanumeric': 0.1511947557623176, 'fraction_numerical': 0.006766758299851977, 'mean_word_length': 1.8965094917330068, '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': '3580111', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1249, 'n_words': 222}