<commit_before>'use strict';

var pollcatControllers = angular.module('pollcatControllers', []);

pollcatControllers.controller('QuestionDetailCtrl', function($scope, $http, $routeParams){
    $http.get('http://localhost:8000/' + $routeParams.id).success(function(data) {
    $scope.detail = data;
    });

  });


pollcatControllers.controller('QuestionListCtrl', ['$scope', '$http', function($scope, $http) {
  $http.get('http://localhost:8000').success(function(data) {
    $scope.questions = data;

  });

  $scope.orderProp = 'id';
}]);

pollcatControllers.controller('PollListController', function($scope){

})

//Login Function




<commit_msg>Added login JWT code, test passed<commit_after>'use strict';

var pollcatControllers = angular.module('pollcatControllers', []);

pollcatControllers.controller('QuestionDetailCtrl', function($scope, $http, $routeParams){
    $http.get('http://localhost:8000/' + $routeParams.id).success(function(data) {
    $scope.detail = data;
    });

  });


pollcatControllers.controller('QuestionListCtrl', ['$scope', '$http', function($scope, $http) {
  $http.get('http://localhost:8000').success(function(data) {
    $scope.questions = data;

  });

  $scope.orderProp = 'id';
}]);

pollcatControllers.controller('PollListController', function($scope){

})

//Login Function


pollcatControllers.controller('UserCtrl', function ($scope, $http, $window) {
  $scope.user = {username: 'john.doe', password: '<PASSWORD>'};
  $scope.message = '';
  $scope.submit = function () {
    $http
      .post('http://localhost:8000/login/', $scope.user)
      .success(function (data, status, headers, config) {
        $window.sessionStorage.token = data.token;
        $scope.message = 'Welcome';
          console.log($scope.message);
      })
      .error(function (data, status, headers, config) {
        // Erase the token if the user fails to log in
        delete $window.sessionStorage.token;

        // Handle login errors here
        $scope.message = 'Error: Invalid user or password';
          console.log($scope.message);
      });
  };
});


{'fraction_non_alphanumeric': 0.1761608425083772, 'fraction_numerical': 0.009573958831977022, 'mean_word_length': 4.072815533980583, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1738461', 'n_tokens_mistral': 657, 'n_tokens_neox': 634, 'n_words': 113}