<commit_before>'use strict';

var app = angular.module('myApp.access-token.services', ['ngResource']);

app.factory('RefreshToken', ['$q', '$http', function($q, $http) {

  var refresh = function(token) {
    var deferred = $q.defer();
    $http({
      method: 'GET',
      url: '/auth/refreshToken',
      params: {token: token}
    }).
    success(function(msg) {
      deferred.resolve(msg);
    }).
    error(function(err,a) {
      deferred.reject(err);
    });
    return deferred.promise;
  };

  return {
    refresh: refresh,
  };

}]);

app.factory('AccessToken', ['$cookies', '$q', function($cookies, $q) {

  var domain = function() {
    var uri = new window.URI(window.location.href);
    var host = uri.domain();
    return '.' + host;
  };

  var set = function(token) {
    $cookies.put('_cta', token, { domain: domain() });
    return true;
  };

  var del = function() {
    var d = domain();
    $cookies.remove('_cta', { domain: d });
    $cookies.remove('_cta');
  };

  var get = function() {
    var ls;
    
    //prefere url token to cookie
    var params = document.location.href.match(/[?&]token=([0-9a-f]+)/);
    if (params) {
      ls = params[1];
      set(ls);
    } else {
      ls = $cookies.get('_cta', { domain: domain() });
    }

    return ls;
  };

  return {
    set: set,
    del: del,
    get: get,
  };

}]);<commit_msg>depreciated http callback<commit_after>'use strict';

var app = angular.module('myApp.access-token.services', ['ngResource']);

app.factory('RefreshToken', ['$q', '$http', function($q, $http) {

  var refresh = function(token) {
    var deferred = $q.defer();
    $http({
      method: 'GET',
      url: '/auth/refreshToken',
      params: {token: token}
    }).then(function(msg) {
      deferred.resolve(msg);
    }, function(err) {
      deferred.reject(err);
    });
    return deferred.promise;
  };

  return {
    refresh: refresh,
  };

}]);

app.factory('AccessToken', ['$cookies', '$q', function($cookies, $q) {

  var domain = function() {
    var uri = new window.URI(window.location.href);
    var host = uri.domain();
    return '.' + host;
  };

  var set = function(token) {
    $cookies.put('_cta', token, { domain: domain() });
    return true;
  };

  var del = function() {
    var d = domain();
    $cookies.remove('_cta', { domain: d });
    $cookies.remove('_cta');
  };

  var get = function() {
    var ls;

    //prefere url token to cookie
    var params = document.location.href.match(/[?&]token=([0-9a-f]+)/);
    if (params) {
      ls = params[1];
      set(ls);
    } else {
      ls = $cookies.get('_cta', { domain: domain() });
    }

    return ls;
  };

  return {
    set: set,
    del: del,
    get: get,
  };

}]);
{'fraction_non_alphanumeric': 0.19749908054431775, 'fraction_numerical': 0.002206693637366679, 'mean_word_length': 2.6026490066225167, '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': '5709214', 'n_tokens_mistral': 979, 'n_tokens_neox': 948, 'n_words': 206}