<commit_before>sbapp.controller('CreateController', [
  '$scope',
  'ProjectService',
  CreateController
]);

function CreateController($scope, ProjectService) {
  // Expose variables and functions to the view:
  var vm = this;
  vm.error = null;

  console.log('Loaded Create Controller');

  //If the user has not logged in, redirect them to the login
  // (IF USER == NULL)
  if($scope.currentUser == null){
    console.log('USER IS NULL');
    window.location.replace('/#/login');
  }

  vm.addProject = function (name, description) {
    console.log('Add Project called');

    ProjectService.addProject(name, description, $scope.currentUser.id)
      .then(
        function (project) { vm.error = ''; },
        function (res) {
          vm.error = 'Couldn\'t create project';
          for (item in res.data.invalidAttributes) {
            vm.error += res.data.invalidAttributes[item][0].message + '\r\n';
          }
        }
      );
  };

  // vm.register = function (username, email, password, passwordVerify) {
  //   if (password != passwordVerify) {
  //     vm.reg.error = 'Passwords do not match'
  //   } else {
  //     AuthService.register(username, email, password)
  //       .then(
  //         function (res) {
  //           $state.go('login');
  //         },
  //         function (res) {
  //           vm.reg.error = '';
  //           for (item in res.data.invalidAttributes) {
  //             vm.reg.error += res.data.invalidAttributes[item][0].message;
  //           }
  //         }
  //       );
  //   }<commit_msg>Removed redirect and replaced with error<commit_after>sbapp.controller('CreateController', [
  '$scope',
  'ProjectService',
  CreateController
]);

function CreateController($scope, ProjectService) {
  // Expose variables and functions to the view:
  var vm = this;
  vm.error = null;

  console.log('Loaded Create Controller');


  vm.addProject = function (name, description) {
    console.log('Add Project called');
    if($scope.currentUser == null){
      console.log('USER IS NULL');
    }else{
      ProjectService.addProject(name, description, $scope.currentUser.id)
        .then(
          function (project) { vm.error = ''; },
          function (res) {
            vm.error = 'Couldn\'t create project';
            for (item in res.data.invalidAttributes) {
              vm.error += res.data.invalidAttributes[item][0].message + '\r\n';
            }
          }
        );
    }
  };

  // vm.register = function (username, email, password, passwordVerify) {
  //   if (password != passwordVerify) {
  //     vm.reg.error = 'Passwords do not match'
  //   } else {
  //     AuthService.register(username, email, password)
  //       .then(
  //         function (res) {
  //           $state.go('login');
  //         },
  //         function (res) {
  //           vm.reg.error = '';
  //           for (item in res.data.invalidAttributes) {
  //             vm.reg.error += res.data.invalidAttributes[item][0].message;
  //           }
  //         }
  //       );
  //   }
{'fraction_non_alphanumeric': 0.1545782737118477, 'fraction_numerical': 0.0013127666557269445, 'mean_word_length': 1.9765625, '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': '5205320', 'n_tokens_mistral': 901, 'n_tokens_neox': 894, 'n_words': 192}