<commit_before>Template.home.helpers({
  myAppVariable: function() {
    return Session.get('myAppVariable');
  }
});

Template.home.rendered = function() {
  Session.set('loginError', '');
}

Template.home.events({
  'submit .login': function(event, template) {
    event.preventDefault();

    var email = event.target.email.value;
    var password = event.target.password.value;

    if (validateInput(email) && validateInput(password)) {
      Session.set('loginError', '');
    } else {
      Session.set('loginError', 'All inputs are required');
    }

    var emailExists = Meteor.call('emailExists', email, function(error, result) {
      if (error) {
        console.log(error);
        return;
      } else {
        if (result) {
          Meteor.call('getUserType', email, function(error, result) {
            user_type = result;
            console.log('user_type: ' + user_type);
            switch (user_type) {
              case 'facebook':
                Meteor.loginWithFacebook({
                  requestPermissions: ['email', 'user_friends'],
                  loginStyle: 'redirect',
                  redirectUrl: Meteor.absoluteUrl() + "list"
                }, function(error) {
                  if (error) {
                    console.log(error);
                  } else {
                    window.location.href = Meteor.absoluteUrl() + "list";
                  }
                });
                break;
              case 'google':
                Meteor.loginWithGoogle({
                  requestPermissions: ['email', 'profile'],
                  loginStyle: "redirect",
                  redirectUrl: Meteor.absoluteUrl() + "list"
                }, function(error) {
                  if (error) {
                    console.log(error);
                  } else {
                    Router.go('list');
                  }
                });
              default:
                Meteor.loginWithPassword({
                  'email': email
                }, password, function(error) {
                  if (error) {
                    console.log(error);
                  } else {
                    Router.go('list')
                  }
                })
            }
          });

        } else {
          Accounts.createUser({<commit_msg>use Router.go instead of window.location<commit_after>Template.home.helpers({
  myAppVariable: function() {
    return Session.get('myAppVariable');
  }
});

Template.home.rendered = function() {
  Session.set('loginError', '');
}

Template.home.events({
  'submit .login': function(event, template) {
    event.preventDefault();

    var email = event.target.email.value;
    var password = event.target.password.value;

    if (validateInput(email) && validateInput(password)) {
      Session.set('loginError', '');
    } else {
      Session.set('loginError', 'All inputs are required');
    }

    var emailExists = Meteor.call('emailExists', email, function(error, result) {
      if (error) {
        console.log(error);
        return;
      } else {
        if (result) {
          Meteor.call('getUserType', email, function(error, result) {
            user_type = result;
            console.log('user_type: ' + user_type);
            switch (user_type) {
              case 'facebook':
                Meteor.loginWithFacebook({
                  requestPermissions: ['email', 'user_friends'],
                  loginStyle: 'redirect',
                  redirectUrl: Meteor.absoluteUrl() + "list"
                }, function(error) {
                  if (error) {
                    console.log(error);
                  } else {
                    Router.go('list');
                  }
                });
                break;
              case 'google':
              Meteor.loginWithGoogle({
                  requestPermissions: ['email', 'profile'],
                  loginStyle: "redirect",
                  redirectUrl: Meteor.absoluteUrl() + "list"
                }, function(error) {
                  if (error) {
                    console.log(error);
                  } else {
                    Router.go('list');
                  }
                });
              default:
                Meteor.loginWithPassword({
                  'email': email
                }, password, function(error) {
                  if (error) {
                    console.log(error);
                  } else {
                    Router.go('list')
                  }
                })
            }
          });

        } else {
          Accounts.createUser({
{'fraction_non_alphanumeric': 0.12336530078465563, 'fraction_numerical': 0.0, 'mean_word_length': 1.3329944077275038, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4584554', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1117, 'n_words': 207}