<commit_before>angular.module('starter.controllers')

.controller('loginCtrl', function($scope, $ionicModal, $state, $ionicHistory, Profile, $http) {
  /*Dealings of the Ionic to clear navigation history*/
  $ionicHistory.clearHistory();

  /*Function to login with the Facebook and set the user on the services*/
  $scope.fbLogin = function () {
    var ref = new Firebase("https://partiuapp.firebaseio.com");
    ref.authWithOAuthPopup("facebook", function(error, authData) {
        if (error) {
            console.log("Login Failed!", error);
        } else {
            console.log("Authenticated successfully with payload:", authData);
            var data = authData.facebook;
            if(data.cachedUserProfile.gender == 'male') {
                data.cachedUserProfile.gender = 'Masculino';
            }
            else if(data.cachedUserProfile.gender == 'female') {
                data.cachedUserProfile.gender = 'Feminino';
            }

            Profile.setUser(data.displayName, data.email, data.accessToken, data.cachedUserProfile.gender, data.profileImageURL, data.id, data.cachedUserProfile.link);

            var requestData = {
              "user": {
                "name": data.displayName,
                "email": data.email,
                "facebook_id": data.id,
                "photo_url": data.profileImageURL
              }
            }

            $http.post('http://localhost:3000/api/users', requestData).success(function(data) {
            });

            $http.get('http://localhost:3000/api/get_user_id', {params:{"facebook_id": data.id}}).success(function(idData) {
              Profile.updateBackendId(idData);

            });
            $state.go('menu.home');
        }
    }, {
        remember: "default",
        scope: "email, public_profile, user_friends, user_about_me, publish_actions"
    });
  };
})<commit_msg>Fix bug: user_id was not setted in the register<commit_after>angular.module('starter.controllers')

.controller('loginCtrl', function($scope, $ionicModal, $state, $ionicHistory, Profile, $http) {
  /*Dealings of the Ionic to clear navigation history*/
  $ionicHistory.clearHistory();

  /*Function to login with the Facebook and set the user on the services*/
  $scope.fbLogin = function () {
    var ref = new Firebase("https://partiuapp.firebaseio.com");
    ref.authWithOAuthPopup("facebook", function(error, authData) {
        if (error) {
            console.log("Login Failed!", error);
        } else {
            console.log("Authenticated successfully with payload:", authData);
            var data = authData.facebook;
            if(data.cachedUserProfile.gender == 'male') {
                data.cachedUserProfile.gender = 'Masculino';
            }
            else if(data.cachedUserProfile.gender == 'female') {
                data.cachedUserProfile.gender = 'Feminino';
            }

            Profile.setUser(data.displayName, data.email, data.accessToken, data.cachedUserProfile.gender, data.profileImageURL, data.id, data.cachedUserProfile.link);

            var requestData = {
              "user": {
                "name": data.displayName,
                "email": data.email,
                "facebook_id": data.id,
                "photo_url": data.profileImageURL
              }
            };

            $http.get('http://localhost:3000/api/get_user_id', {params:{"facebook_id": data.id}})
              .then(function(response) {
                Profile.updateBackendId(response.data);
              }, function(error) {
                $http.post('http://localhost:3000/api/users', requestData).
                  success(function(user) {
                    Profile.updateBackendId(user.id);
                  });
              });

            $state.go('menu.home');
        }
    }, {
        remember: "default",
        scope: "email, public_profile, user_friends, user_about_me, publish_actions"
    });
  };
})
{'fraction_non_alphanumeric': 0.13169246384166455, 'fraction_numerical': 0.0040598832783557475, 'mean_word_length': 2.17135961383749, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '949179', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1061, 'n_words': 202}