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

  /*
   * Application wide view controller
   */
  angular.module('core').controller('AppController', ['$scope', '$rootScope', '$window', '$state', 'Authentication', 'messageCenterService', 'SettingsFactory',
    function($scope, $rootScope, $window, $state, Authentication, messageCenterService, SettingsFactory) {

      // ViewModel
      var vm = this;

      // Exposed
      vm.user = Authentication.user;
      vm.appSettings = SettingsFactory.get();
      vm.goHome = goHome;

      // Used as a cache buster with ng-include
      // Includes a hash of latest git commit
      vm.cacheBust = vm.appSettings.commit || '';

      /**
       * Determine where to direct user from "home" links
       */
      function goHome() {
        if(Authentication.user) {
          $state.go('search');
        }
        else {
          $state.go('home');
        }
      }

      // Receive user changes
      $scope.$on('userUpdated', function(){
        vm.user = Authentication.user;
      });

      // Before page change
      $scope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {

        // Redirect to login page if no user
        if (toState.requiresAuth && !Authentication.user) {
          // Cancel stateChange
          event.preventDefault();

          // Save previous state
          // See modules/users/client/controllers/authentication.client.controller.js for how they're used
          $rootScope.signinState = toState.name;
          $rootScope.signinStateParams = toParams;
          $state.go('signin-continue', {'continue': true});
        }

      });

      // After page change
      $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {

        // Reset page scroll on page change
        $window.scrollTo(0,0);

        // Analytics
        if (typeof(ga) === 'function') {
          ga('send', 'pageview', {
            'page': toState.url,
            //'title': ''
          });
        }

      });

    }<commit_msg>Redirect logged in users away from home page<commit_after>(function(){
  'use strict';

  /*
   * Application wide view controller
   */
  angular.module('core').controller('AppController', ['$scope', '$rootScope', '$window', '$state', 'Authentication', 'messageCenterService', 'SettingsFactory',
    function($scope, $rootScope, $window, $state, Authentication, messageCenterService, SettingsFactory) {

      // ViewModel
      var vm = this;

      // Exposed
      vm.user = Authentication.user;
      vm.appSettings = SettingsFactory.get();
      vm.goHome = goHome;

      // Used as a cache buster with ng-include
      // Includes a hash of latest git commit
      vm.cacheBust = vm.appSettings.commit || '';

      /**
       * Determine where to direct user from "home" links
       */
      function goHome() {
        if(Authentication.user) {
          $state.go('search');
        }
        else {
          $state.go('home');
        }
      }

      // Receive user changes
      $scope.$on('userUpdated', function(){
        vm.user = Authentication.user;
      });

      // Before page change
      $scope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {

        // Redirect away from frontpage if user is authenticated
        if(toState.name === 'home' && Authentication.user) {
          event.preventDefault();
          $state.go('search');
        }

        // Redirect to login page if no user
        if (toState.requiresAuth && !Authentication.user) {
          // Cancel stateChange
          event.preventDefault();

          // Save previous state
          // See modules/users/client/controllers/authentication.client.controller.js for how they're used
          $rootScope.signinState = toState.name;
          $rootScope.signinStateParams = toParams;
          $state.go('signin-continue', {'continue': true});
        }

      });

      // After page change
      $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {

        // Reset page scroll on page change
        $window.scrollTo(0,0);

        // Analytics
        if (typeof(ga) === 'function') {
          ga('send', 'pageview', {
            'page': toState.url,
            //'title': ''
          });
        }

      });

    }
{'fraction_non_alphanumeric': 0.13643623089208304, 'fraction_numerical': 0.0009126169290440338, 'mean_word_length': 2.1202846975088967, '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': '6740260', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1172, 'n_words': 286}