<commit_before>if (Meteor.isClient) {

  
  // ROUTES 

  Router.map(function () {
    
    this.route('frontpage', { path: '/', template: 'frontpage' });

    this.route('highlights', { path: '/highlights', template: 'highlights' });
    
    this.route('hackers', { path: '/hackers', template: 'hackers' });

    this.route('invitations', { path: '/invitations', template: 'invitations' });

    this.route('agenda', { path: '/agenda', template: 'agenda' });
    
    this.route('about', { path: '/about', template: 'about' });

    this.route('places', { path: '/places', template: 'places',
      load: function() { 
        Session.set('absoluteHeader', true); 
        Session.set('inversedHeader', true); 
      },
      unload: function() {
        Session.set('absoluteHeader', false); 
        Session.set('inversedHeader', false); 
      }
    });

    this.route('verifyEmail', {path: '/verify-email/:token',
      load: function() {
        var token = this.params.token;
        
        // log to google analytics
        Meteor.call('getEmailVerificationTokenUser', token, function(err, user) {
          if (!err && user) 
            GAnalytics.event('EmailVerification', 'verified user', user._id);
          else GAnalytics.event('EmailVerification', 'invalid token', token);
        });
      },
      action: function() {
        Accounts.verifyEmail(this.params.token, checkAccess);
        Router.go('hackers');
        this.stop();
      }
    });
    
    this.route('hacker', { path: '/:localRankHash', template: 'hacker', 
      load: function() {
        var city = 'lyon';
        var localRankHash = this.params.localRankHash;
        var localRank = bitHashInv(localRankHash);
        var hacker = Meteor.users.findOne({city: city, localRank: localRank}, {reactive: false});
        
        // log to google analytics
        if (hacker)
          GAnalytics.event('Views', 'profile', hacker._id);
        else GAnalytics.event('Views', 'profile unknow', city+' '+localRank);
      },
      before: function() { 
        var city = 'lyon';
        var localRankHash = this.params.localRankHash;
        var localRank = bitHashInv(localRankHash);
        var hacker = Meteor.users.findOne({city: city, localRank: localRank});
        
        if (!hacker)
          return this.redirect('frontpage');
        
        Session.set('hackerId', hacker._id);
        Session.set('hacker', hacker);
        Session.set('hackerEditMode', true);
      },
      unload: function() {
        Session.set('hackerId', null);
        Session.set('hacker', null);
      }
    });


    this.route('invite', { path: /^\/\+\/(.*)/, template: 'frontpage',
      before: function() {
        var phrase = bitHashInv(this.params[0]);
        
        Session.set('invitationPhrase', phrase);

        // get associated broadcast user
        Meteor.call('getBroadcastUser', phrase, function(err, broadcastUser) {
          Session.set('invitationBroadcastUser', broadcastUser);
        });

        this.redirect('frontpage');
      }
    });
  

  });




  /* resolve url helpers */

  Router.routes['invite'].url = function(params) {
    return Meteor.absoluteUrl('+/' + params.phrase);
  }



  /* custom functionality */

  // XXX in iron-router you can't call this.redirect() if you want
  // that the unload event must be triggered. Instead you must use
  // Router.go() and then stopping the current route with this.stop()
  //
  // It is not recommend to set session variables in the before/load functions
  // this will trigger a recomputation of the route


  // wait to the subscriptions are fully loaded before rendering a template
  var waitOnSubscriptionsReady = function() {
    if (!Session.get('subscriptionsReady'))
      this.stop();  
  }

  // when login is required, render the frontpage
  var loginRequired = function() {

    switch (Session.get('currentLoginState')) {
      
      case 'loggedOut':
        // redirect to frontpage so that the user can login
        Session.set('redirectUrl', location.pathname + location.search + location.hash);
        Router.go('frontpage'); 
        this.stop();  
        break;

      case 'loggingIn':
        // make sure that the user subscriptions are ready first
        this.stop();
        break;
    }

  }

  // check if there are duplicate accounts, if so request for merge
  var checkDuplicateAccounts = function() {
    if (Session.get('requestMergeDuplicateAccount')) {
      this.render('requestMergeDuplicateAccount');
      this.stop();
    }
  }
<commit_msg>bugfix: redirect after login<commit_after>if (Meteor.isClient) {

  
  // ROUTES 

  Router.map(function () {
    
    this.route('frontpage', { path: '/', template: 'frontpage' });

    this.route('highlights', { path: '/highlights', template: 'highlights' });
    
    this.route('hackers', { path: '/hackers', template: 'hackers' });

    this.route('invitations', { path: '/invitations', template: 'invitations' });

    this.route('agenda', { path: '/agenda', template: 'agenda' });
    
    this.route('about', { path: '/about', template: 'about' });

    this.route('places', { path: '/places', template: 'places',
      load: function() { 
        Session.set('absoluteHeader', true); 
        Session.set('inversedHeader', true); 
      },
      unload: function() {
        Session.set('absoluteHeader', false); 
        Session.set('inversedHeader', false); 
      }
    });

    this.route('verifyEmail', {path: '/verify-email/:token',
      load: function() {
        var token = this.params.token;
        
        // log to google analytics
        Meteor.call('getEmailVerificationTokenUser', token, function(err, user) {
          if (!err && user) 
            GAnalytics.event('EmailVerification', 'verified user', user._id);
          else GAnalytics.event('EmailVerification', 'invalid token', token);
        });
      },
      action: function() {
        Accounts.verifyEmail(this.params.token, checkAccess);
        Router.go('hackers');
        this.stop();
      }
    });
    
    this.route('hacker', { path: '/:localRankHash', template: 'hacker', 
      load: function() {
        var city = 'lyon';
        var localRankHash = this.params.localRankHash;
        var localRank = bitHashInv(localRankHash);
        var hacker = Meteor.users.findOne({city: city, localRank: localRank}, {reactive: false});
        
        // log to google analytics
        if (hacker)
          GAnalytics.event('Views', 'profile', hacker._id);
        else GAnalytics.event('Views', 'profile unknow', city+' '+localRank);
      },
      before: function() { 
        var city = 'lyon';
        var localRankHash = this.params.localRankHash;
        var localRank = bitHashInv(localRankHash);
        var hacker = Meteor.users.findOne({city: city, localRank: localRank});
        
        if (!hacker)
          return this.redirect('frontpage');
        
        Session.set('hackerId', hacker._id);
        Session.set('hacker', hacker);
        Session.set('hackerEditMode', true);
      },
      unload: function() {
        Session.set('hackerId', null);
        Session.set('hacker', null);
      }
    });


    this.route('invite', { path: /^\/\+\/(.*)/, template: 'frontpage',
      before: function() {
        var phrase = bitHashInv(this.params[0]);
        
        Session.set('invitationPhrase', phrase);

        // get associated broadcast user
        Meteor.call('getBroadcastUser', phrase, function(err, broadcastUser) {
          Session.set('invitationBroadcastUser', broadcastUser);
        });

        this.redirect('frontpage');
      }
    });
  

  });




  /* resolve url helpers */

  Router.routes['invite'].url = function(params) {
    return Meteor.absoluteUrl('+/' + params.phrase);
  }



  /* custom functionality */

  // XXX in iron-router you can't call this.redirect() if you want
  // that the unload event must be triggered. Instead you must use
  // Router.go() and then stopping the current route with this.stop()
  //
  // It is not recommend to set session variables in the before/load functions
  // this will trigger a recomputation of the route


  // wait to the subscriptions are fully loaded before rendering a template
  var waitOnSubscriptionsReady = function() {
    if (!Session.get('subscriptionsReady'))
      this.stop();  
  }

  // when login is required, render the frontpage
  var loginRequired = function() {

    switch (Session.get('currentLoginState')) {
      
      case 'loggedOut':
        // redirect to frontpage so that the user can login
        if (location.pathname != "/")
          Session.set('redirectUrl', location.pathname + location.search + location.hash);
        Router.go('frontpage'); 
        this.stop();  
        break;

      case 'loggingIn':
        // make sure that the user subscriptions are ready first
        this.stop();
        break;
    }

  }

  // check if there are duplicate accounts, if so request for merge
  var checkDuplicateAccounts = function() {
    if (Session.get('requestMergeDuplicateAccount')) {
      this.render('requestMergeDuplicateAccount');
      this.stop();
    }
  }

{'fraction_non_alphanumeric': 0.14407241792998146, 'fraction_numerical': 0.0002181262951248773, 'mean_word_length': 2.4866920152091256, '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': '4454059', 'n_tokens_mistral': 2691, 'n_tokens_neox': 2570, 'n_words': 637}