<commit_before>'use strict';

angular.module('users').controller('AuthenticationController', ['$scope', '$state', '$http', '$location', '$window', 'Authentication', 'PasswordValidator',
  function ($scope, $state, $http, $location, $window, Authentication, PasswordValidator) {
    $scope.authentication = Authentication;
    $scope.popoverMsg = PasswordValidator.getPopoverMsg();

    // Get an eventual error defined in the URL query string:
    $scope.error = $location.search().err;

    // If user is signed in then redirect to correct landing page
    if ($scope.authentication.user) {
      if ($scope.authentication.user.admin) {
        $location.path('/admin_landing');
      }
      else if (!$scope.authentication.user.admin){
        $location.path('/patients');
      }
    }

    $scope.signup = function (isValid) {
      $scope.error = null;

      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'userForm');

        return false;
      }

      $http.post('/api/auth/signup', $scope.credentials).success(function (response) {<commit_msg>Ryan added user portal<commit_after>'use strict';

angular.module('users').controller('AuthenticationController', ['$scope', '$state', '$http', '$location', '$window', 'Authentication', 'PasswordValidator',
  function ($scope, $state, $http, $location, $window, Authentication, PasswordValidator) {
    $scope.authentication = Authentication;
    $scope.popoverMsg = PasswordValidator.getPopoverMsg();

    // Get an eventual error defined in the URL query string:
    $scope.error = $location.search().err;

    // If user is signed in then redirect to correct landing page
    if ($scope.authentication.user) {
      if ($scope.authentication.user.admin) {
        $location.path('/admin_landing');
      }
      else if (!$scope.authentication.user.admin){
        $location.path('/patients');
      }
    }
    // Else (not logged in) cannot access any page but the index page
    else {
      $location.path('/');
    }

    // Title links to certain landing page based on whether an admin or a user is logged in
    $scope.logoState = function() {
      if ($scope.authentication.user) {
        if ($scope.authentication.user.admin) {
          return "admin-landing";
        }
        else if (!$scope.authentication.user.admin) {
          return "patients.list";
        }
      }
      else {
        return "home";
      }
    };

    $scope.signup = function (isValid) {
      $scope.error = null;

      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'userForm');

        return false;
      }

      $http.post('/api/auth/signup', $scope.credentials).success(function (response) {
{'fraction_non_alphanumeric': 0.14761376248612654, 'fraction_numerical': 0.0, 'mean_word_length': 2.976470588235294, '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': '3837165', 'n_tokens_mistral': 768, 'n_tokens_neox': 750, 'n_words': 187}