<commit_before>function LoginControllerUUID($scope, $http, $location, $modalInstance, userService, uuid) {
  $scope.login = {
    uuid: uuid
  }

  Login($scope, $http, $location, $modalInstance, userService);
}

function LoginController($scope, $http, $location, $modalInstance, userService) {
  Login($scope, $http, $location, $modalInstance, userService);
}

// Helper (Not sure if this can be fixed with providers)
function Login($scope, $http, $location, $modalInstance, userService) {
  $scope.open = function(login) {
    var postData = {
      type: 'RESTOREWALLET',
      uuid: login.uuid
    }
    $http({
        url: '/v1/user/wallet/restore/',
        method: 'POST',
        data: postData,
        headers: {'Content-Type': 'application/json'}
    })
    .success(function (data, status, headers, config) {
      console.log(data);
      if(data.status == "MISSING") {
        $scope.missingUUID = true;
      } else {
        var passwordHash = data.wallet.passwordHash;
        var salt = data.wallet.salt;
        var loginHash = Crypto.SHA256(login.password + salt);

        if(loginHash == passwordHash) {
          console.log(data.wallet);
          userService.login(data.wallet);
          $modalInstance.close();
          $location.path('/wallet');
        } else {
          $scope.badPassword = true;
        }
      }
    })
    .error(function(data, status, headers, config) {
      $scope.serverError = true;
    });
  }
}<commit_msg>Update Login controller to new login scheme<commit_after>function LoginControllerUUID($scope, $http, $location, $modalInstance, userService, uuid) {
  $scope.login = {
    uuid: uuid
  }

  Login($scope, $http, $location, $modalInstance, userService);
}

function LoginController($scope, $http, $location, $modalInstance, userService) {
  Login($scope, $http, $location, $modalInstance, userService);
}

// Helper (Not sure if this can be fixed with providers)
function Login($scope, $http, $location, $modalInstance, userService) {
  $scope.open = function(login) {
    var uuid = login.uuid;
    var asymKey = {};
    var walletKey = '';

    $http.get('/flask/challenge?uuid='+uuid)
      .then(function(result) {
        var data = result.data;
        var nonce = CryptUtil.generateNonceForDifficulty(data.pow_challenge);
        walletKey = CryptUtil.generateSymmetricKey(login.password, data.salt);
        asymKey = CryptUtil.generateAsymmetricPair();

        return $http({
          url: '/flask/login',
          method: 'GET',
          params: { nonce: nonce, public_key: asymKey.pubPem, uuid: uuid }
        });
      }, function (result) {
        console.log('error getting salt');
      })
      .then(function(result) {
        var data = result.data;
        console.log(result)
        console.log(data);

        var wallet = CryptUtil.decryptObject(data, walletKey);
        userService.login(wallet, walletKey, asymKey);
        $modalInstance.close()
        $location.path('/wallet');
      }, function(result) {
        $scope.serverError = true;
      });
  }
}
{'fraction_non_alphanumeric': 0.14042553191489363, 'fraction_numerical': 0.001309328968903437, 'mean_word_length': 2.853720050441362, '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': '1848000', 'n_tokens_mistral': 925, 'n_tokens_neox': 922, 'n_words': 202}