<commit_before>'use strict';

/**
 * @ngdoc service
 * @name blimpCockpitApp.cockpit.api
 * @description
 * # cockpit.api
 * Service in the blimpCockpitApp.
 */
angular.module('blimpCockpitApp')
  .factory('cockpitApi', ['$resource', '$http', '$q', '$rootScope', '$state', '$localstorage',
    function ($resource, $http, $q, $rootScope, $state, $localstorage) {

      var localStorageUserKey = 'cloudfleet.cockpit.currentUser';

      var storeCurrentUser = function(user)
      {
        $localstorage.setObject(localStorageUserKey, user);
      };

      var  clearCurrentUser = function()
      {
        $localstorage.getObject(localStorageUserKey, null);
      };

      var service = {

        getCurrentUser: function()
        {
          return $localstorage.getObject(localStorageUserKey);
        },

        login: function (username, password) {

          console.log('logging in user ' + username)

          var deferred = $q.defer();

          $http.post('/musterroll/login', {
            'username': username,
            'password': password
          }).
            success(function () {

              $http.get('/musterroll/api/v1/currentUser').
                success(function(data){
                  storeCurrentUser(data);
                  deferred.resolve(data);
                }).
                error(function () {
                  deferred.resolve(false);

                });
            }).
            error(function () {
              deferred.resolve(false);
<commit_msg>fix first sign in<commit_after>'use strict';

/**
 * @ngdoc service
 * @name blimpCockpitApp.cockpit.api
 * @description
 * # cockpit.api
 * Service in the blimpCockpitApp.
 */
angular.module('blimpCockpitApp')
  .factory('cockpitApi', ['$resource', '$http', '$q', '$rootScope', '$state', '$localstorage',
    function ($resource, $http, $q, $rootScope, $state, $localstorage) {

      var localStorageUserKey = 'cloudfleet.cockpit.currentUser';

      var storeCurrentUser = function(user)
      {
        $localstorage.setObject(localStorageUserKey, user);
      };

      var  clearCurrentUser = function()
      {
        $localstorage.getObject(localStorageUserKey, null);
      };

      var service = {

        getCurrentUser: function()
        {
          return $localstorage.getObject(localStorageUserKey) || {};
        },

        login: function (username, password) {

          console.log('logging in user ' + username)

          var deferred = $q.defer();

          $http.post('/musterroll/login', {
            'username': username,
            'password': password
          }).
            success(function () {

              $http.get('/musterroll/api/v1/currentUser').
                success(function(data){
                  storeCurrentUser(data);
                  deferred.resolve(data);
                }).
                error(function () {
                  deferred.resolve(false);

                });
            }).
            error(function () {
              deferred.resolve(false);

{'fraction_non_alphanumeric': 0.13469119579500657, 'fraction_numerical': 0.000657030223390276, 'mean_word_length': 1.9505813953488371, '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': '6066073', 'n_tokens_mistral': 850, 'n_tokens_neox': 807, 'n_words': 145}