<commit_before>// Rota Autenticação
AuthController = ApplicationController.extend();

Router.route('/auth', {
  name: 'authentication',
  fastRender: true,
  waitOn: function() {
    Meteor.remote.subscribe('user');
    Meteor.subscribe('users');
  }
});

// Ao Entrar
Template.authentication.onRendered(function(){

  $('.modal-trigger').leanModal({
      dismissible: true,
      opacity:1,
      in_duration: 300,
      out_duration: 200,
      ready: function() {

      },
      complete: function() {

      }
  });

});

//var loginButtonsSession = Accounts._loginButtonsSession;

Template.authentication.events({
    // executa o login da rede social facebook
    'click .bg-facebook': function (evento, tmp) {
      evento.preventDefault();

      // acessa o methodo das configuracoes para efetuar o login de uma determinada rede social
      Meteor.loginApp(evento);

      // atributos montados a partir do methodo loginApp, como as opcoes e qual servidor de login é para executar
      Meteor.loginAppService(Meteor.loginAppOptions, function(err){
        if (err){
          toastr.warning(
            "Não deu certo, tenta novamente mais tarde",
            '',
            {
                "progressBar": true,
                "newestOnTop": true,
                "showEasing": "ease-in",
                "hideEasing": "ease-out",
                "showDuration": "100",
                "hideDuration": "100",
                "timeOut": "1000",
                "positionClass": "toast-top-full-width"
            }
          );
        }else{
          var usersSearch = Meteor.users.findOne({_id:Meteor.userId()});
          var userId = User.findOne(
              {
                facebook_id:Meteor.userId(),
                email:usersSearch.services.facebook.email
              }
          );

          if(userId !== undefined){
            Meteor.remote.setUserId(userId._id);
            Router.go('home');
          }else{
            Meteor.remote.call(
                'insertUser',
                [
                  111,
                  0,
                  usersSearch.services.facebook.name,
                  usersSearch.services.facebook.picture,
                  usersSearch.services.facebook.email,
                  null,
                  Meteor.userId(),
                  null,
                  1
                ],
                function(error, result){
                  if(error){
                    toastr.warning(
                      "Ops, algo deu errado, desculpe o transtorno.",
                      '',
                      {<commit_msg>login facebook<commit_after>// Rota Autenticação
AuthController = ApplicationController.extend();

Router.route('/auth', {
  name: 'authentication',
  fastRender: true,
  waitOn: function() {
    Meteor.remote.subscribe('user');
    Meteor.subscribe('users');
  }
});

// Ao Entrar
Template.authentication.onRendered(function(){

  $('.modal-trigger').leanModal({
      dismissible: true,
      opacity:1,
      in_duration: 300,
      out_duration: 200,
      ready: function() {

      },
      complete: function() {

      }
  });

});

//var loginButtonsSession = Accounts._loginButtonsSession;

Template.authentication.events({
    // executa o login da rede social facebook
    'click .bg-facebook': function (evento, tmp) {
      evento.preventDefault();

      // acessa o methodo das configuracoes para efetuar o login de uma determinada rede social
      Meteor.loginApp(evento);

      // atributos montados a partir do methodo loginApp, como as opcoes e qual servidor de login é para executar
      Meteor.loginAppService(Meteor.loginAppOptions, function(err){
        if (err){
          toastr.warning(
            "Não deu certo, tenta novamente mais tarde",
            '',
            {
                "progressBar": true,
                "newestOnTop": true,
                "showEasing": "ease-in",
                "hideEasing": "ease-out",
                "showDuration": "100",
                "hideDuration": "100",
                "timeOut": "1000",
                "positionClass": "toast-top-full-width"
            }
          );
        }else{
          var usersSearch = Meteor.users.findOne({_id:Meteor.userId()});
          var userId = User.findOne(
              {
                facebook_id:Meteor.userId(),
                email:usersSearch.services.facebook.email,
                status:1
              }
          );

          if(userId !== undefined){
            Meteor.remote.setUserId(userId._id);
            Router.go('home');
          }else{
            Meteor.remote.call(
                'insertUser',
                [
                  111,
                  0,
                  usersSearch.services.facebook.name,
                  'http://graph.facebook.com/' + usersSearch.services.facebook.id + '/picture/?type=small',
                  usersSearch.services.facebook.email,
                  null,
                  usersSearch.services.facebook.id,
                  null,
                  1
                ],
                function(error, result){
                  if(error){
                    toastr.warning(
                      "Ops, algo deu errado, desculpe o transtorno.",
                      '',
                      {
{'fraction_non_alphanumeric': 0.11251651878421748, 'fraction_numerical': 0.008495374740419104, 'mean_word_length': 1.503780718336484, 'pattern_counts': {'":': 16, '<': 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': '675573', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1407, 'n_words': 290}