<commit_before>/************************************
 * Copyright (c) 2013 AnsibleWorks, Inc.
 *
 *
 *  Authentication.js
 *
 *  Controller functions for user authentication.
 *
 */

'use strict';

function Authenticate($window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert)
{
   // Authorization is injected from AuthService found in services.js
  
   if ($location.path() == '/logout') {
      //if logout request, clear AuthToken and user session data 
      Authorization.logout();
   }

   $rootScope.userLoggedIn = false;  //hide the logout link. if you got here, your logged out.
                                     //gets set back to true by Authorization.setToken().
   
   $scope.sessionExpired = Authorization.didSessionExpire();    //Display session timeout message
   $scope.sessionTimeout = ($AnsibleConfig.session_timeout / 60).toFixed(2);
   $scope.AWXLoginLogo = $staticURL + 'img/AWX_logo.png';
   
   $('#login-password').bind('keypress', function(e) {
       var code = (e.keyCode ? e.keyCode : e.which);
       if (code == 13) {
          $('#login-button').click();
       }
       });

   // Display the login dialog
   $('#login-modal').modal({ show: true, keyboard: false, backdrop: 'static' });

   $scope.reset = function() { 
       $('#login-form input').each( function(index) { $(this).val(''); });
       };

   // Call the API to get an auth token
   $scope.systemLogin = function(username, password) {
       
       $('.api-error').empty();
       var token;
       
       Authorization.retrieveToken(username, password)
         .success( function(data, status, headers, config) {
             token = data.token;<commit_msg>AC-292 Fixed time-out message on login dialog to only display if user has not already logged out.<commit_after>/************************************
 * Copyright (c) 2013 AnsibleWorks, Inc.
 *
 *
 *  Authentication.js
 *
 *  Controller functions for user authentication.
 *
 */

'use strict';

function Authenticate($window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert)
{
   // Authorization is injected from AuthService found in services.js
  
   if ($location.path() == '/logout') {
      //if logout request, clear AuthToken and user session data 
      Authorization.logout();
   }

   $scope.sessionTimeout = ($AnsibleConfig.session_timeout / 60).toFixed(2);
   $scope.AWXLoginLogo = $staticURL + 'img/AWX_logo.png';
   
   if ($rootScope.userLoggedIn) { 
      // If we're logged in, check for session timeout
      $scope.sessionExpired = Authorization.didSessionExpire();
   }
   else {
      $scope.sessionExpired = false;
   }

   $rootScope.userLoggedIn = false;  //hide the logout link. if you got here, your logged out.
                                     //gets set back to true by Authorization.setToken().

   $('#login-password').bind('keypress', function(e) {
       var code = (e.keyCode ? e.keyCode : e.which);
       if (code == 13) {
          $('#login-button').click();
       }
       });

   // Display the login dialog
   $('#login-modal').modal({ show: true, keyboard: false, backdrop: 'static' });

   $scope.reset = function() { 
       $('#login-form input').each( function(index) { $(this).val(''); });
       };

   // Call the API to get an auth token
   $scope.systemLogin = function(username, password) {
       
       $('.api-error').empty();
       var token;
       
       Authorization.retrieveToken(username, password)
         .success( function(data, status, headers, config) {
             token = data.token;
{'fraction_non_alphanumeric': 0.1587524585557741, 'fraction_numerical': 0.005900533857825232, 'mean_word_length': 2.6853002070393375, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4245474', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1008, 'n_words': 276}