Commit 10bb43c11a3e29c4ae4ba9a7e23ff93c5ae5730e
1 parent
fb87f0cd5c
Exists in
master
order line
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/js/requestHeadersInterceptor.js
1 | angular.module('focaConfiguracion') | 1 | angular.module('focaConfiguracion') |
2 | .factory("RequestHeadersInterceptor", [ | 2 | .factory("RequestHeadersInterceptor", [ |
3 | '$localStorage', '$cookies', '$injector', | 3 | '$localStorage', '$cookies', '$injector', |
4 | function($localStorage, $cookies, $injector) { | 4 | function($localStorage, $cookies, $injector) { |
5 | 5 | ||
6 | function getPuntoVenta(config) { | 6 | function getPuntoVenta(config) { |
7 | 7 | ||
8 | var url = $injector.get('API_ENDPOINT').URL; | 8 | var url = $injector.get('API_ENDPOINT').URL; |
9 | 9 | ||
10 | if (url) { | 10 | if (url) { |
11 | 11 | ||
12 | var $http = $injector.get('$http'); | 12 | var $http = $injector.get('$http'); |
13 | var $timeout = $injector.get('$timeout'); | 13 | var $timeout = $injector.get('$timeout'); |
14 | config.url = url + '/config/punto-venta'; | 14 | config.url = url + '/config/punto-venta'; |
15 | 15 | ||
16 | $timeout(function() { | 16 | $timeout(function() { |
17 | $http(config).then(function(res) { | 17 | $http(config).then(function(res) { |
18 | $cookies.put('puntoVenta', res.data[0]); | 18 | $cookies.put('puntoVenta', res.data[0]); |
19 | }); | 19 | }); |
20 | }); | 20 | }); |
21 | } | 21 | } |
22 | } | 22 | } |
23 | 23 | ||
24 | var request = { | 24 | var request = { |
25 | request: function(config) { | 25 | request: function(config) { |
26 | 26 | ||
27 | var nombreUsuario = $cookies.get('nombreUsuario'); | 27 | var nombreUsuario = $cookies.get('nombreUsuario'); |
28 | var puntoVenta = $cookies.get('puntoVenta'); | 28 | var puntoVenta = $cookies.get('puntoVenta'); |
29 | 29 | ||
30 | if (!puntoVenta) { | 30 | if (!puntoVenta) { |
31 | getPuntoVenta(angular.copy(config)); | 31 | getPuntoVenta(angular.copy(config)); |
32 | } | 32 | } |
33 | 33 | ||
34 | config.headers["X-Punto-Venta"] = puntoVenta; | ||
35 | config.headers["X-Terminal-Key"] = $localStorage.terminalKey; | 34 | config.headers["X-Terminal-Key"] = $localStorage.terminalKey; |
36 | config.headers["X-Nombre-Usuario"] = nombreUsuario; | 35 | config.headers["X-Nombre-Usuario"] = nombreUsuario; |
36 | config.headers["X-Punto-Venta"] = puntoVenta; | ||
37 | return config; | 37 | return config; |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | return request; | 41 | return request; |
42 | } | 42 | } |
43 | ]); | 43 | ]); |