<commit_before>angular.module('zeus.account', [])
.controller('AccountController', function($location, $stateParams, Details, User) {
  var AccountVm = this;
  AccountVm.usernameTaken = false;

  //so, Details.getUserFavorites actually returns the whole user record, not just favorites. That's why it's being used here.
  Details.getUserFavorites()
    .then(function(user) {
      AccountVm.email = user.email;
      AccountVm.username = user.username;
      AccountVm.originalUsername = user.username; //for use with HTML validation checking
      AccountVm.about = user.about;
      AccountVm.joinDate = user.joinDate;
      AccountVm.fullName = user.fullName;
      AccountVm.location = user.location;
      AccountVm.profilePic = user.profilePicLink;
    });

  AccountVm.usernameTaken = function(username) {
    var taken = false;
    User.getUserId(username).then(function(res) {
      AccountVm.taken = res;
    });
    return;
  };

  AccountVm.update = function() {
    var updatedAccount = {
      email: AccountVm.email,
      username: AccountVm.username,
      fullName: AccountVm.fullName,
      about: AccountVm.about,
      location: AccountVm.location
    };
    User.editUser(updatedAccount); //starts chain to save info to DB
    $location.path('/user');
  };

  AccountVm.cancel = function(){
    $location.path('/account');
  };

  AccountVm.deleteUser = function() {
    var confirmed = confirm("Are you sure you want to delete your account? Rotten Tomatoes user interface is soooo ugly!!! Are you suuuurrrree???");
    if (confirmed) {
      User.deleteUser();
      $location.path('/');
    }
  };
});<commit_msg>- Fixes deleteUser method<commit_after>angular.module('zeus.account', [])
.controller('AccountController', function($location, $stateParams, Details, User, authService) {
  var AccountVm = this;
  AccountVm.usernameTaken = false;

  //so, Details.getUserFavorites actually returns the whole user record, not just favorites. That's why it's being used here.
  Details.getUserFavorites()
    .then(function(user) {
      AccountVm.email = user.email;
      AccountVm.username = user.username;
      AccountVm.originalUsername = user.username; //for use with HTML validation checking
      AccountVm.about = user.about;
      AccountVm.joinDate = user.joinDate;
      AccountVm.fullName = user.fullName;
      AccountVm.location = user.location;
      AccountVm.profilePic = user.profilePicLink;
    });

  AccountVm.usernameTaken = function(username) {
    var taken = false;
    User.getUserId(username).then(function(res) {
      AccountVm.taken = res;
    });
    return;
  };

  AccountVm.update = function() {
    var updatedAccount = {
      email: AccountVm.email,
      username: AccountVm.username,
      fullName: AccountVm.fullName,
      about: AccountVm.about,
      location: AccountVm.location
    };
    User.editUser(updatedAccount); //starts chain to save info to DB
    $location.path('/user');
  };

  AccountVm.cancel = function(){
    $location.path('/account');
  };

  AccountVm.deleteUser = function() {
    var confirmed = confirm("Are you sure you want to delete your account? Rotten Tomatoes user interface is soooo ugly!!! Are you suuuurrrree???");
    if (confirmed) {
      User.deleteUser()
        .then(function(res){
          authService.logout();
          $location.path('/');
        });
    }
  };
});
{'fraction_non_alphanumeric': 0.12289013917678412, 'fraction_numerical': 0.0, 'mean_word_length': 3.2067247820672478, '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': '6174648', 'n_tokens_mistral': 1031, 'n_tokens_neox': 1007, 'n_words': 234}