{"size": 967, "ext": "js", "max_stars_repo_path": "www/js/facebook.login.controller.js", "max_stars_repo_name": "todoken/ionic-facebook-integration", "max_stars_repo_stars_event_min_datetime": "2015-06-11T04:49:18.000Z", "max_stars_repo_stars_event_max_datetime": "2015-06-11T04:49:18.000Z", "max_issues_repo_path": "www/js/facebook.login.controller.js", "max_issues_repo_name": "todoken/ionic-facebook-integration", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "www/js/facebook.login.controller.js", "max_forks_repo_name": "todoken/ionic-facebook-integration", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.303030303, "max_line_length": 99, "alphanum_fraction": 0.5935884178}
angular.module('starter')
.controller('FacebookLoginController', ['$scope', '$log', '$cordovaFacebook',
  function($scope, $log, $cordovaFacebook) {

    var _this = this;
    var accessToken = null;

    _this.loginWithFacebook = function () {
      $cordovaFacebook.login(['public_profile', 'email', 'user_friends']).then(function(response) {
        $log.log(response);
        return $cordovaFacebook.api('me', ['public_profile']);
      }).then(function(response) {
        $log.log(response);
        $scope.isAuthenticated = true;
        $scope.username = response.name;
      }).catch(function(cause) {
        $log.log(cause);
        $scope.isAuthenticated = false;
      });
    };

    _this.logout = function () {
      $cordovaFacebook.logout().then(function(response) {
        $log.log(response);
        $scope.username = null;
        $scope.isAuthenticated = false;
      }).catch(function(cause) {
        $log.log(cause);
      });
    };

}]);
