Commit 1bf6403d2ad1740dea056469cee3bcd8058c4197
1 parent
bef6f00e59
Exists in
master
nombre headers
Showing
4 changed files
with
23 additions
and
4 deletions
Show diff stats
src/js/app.js
| 1 | 1 | angular.module('focaConfiguracion', ['ngStorage']) |
| 2 | - .run(['$localStorage', 'focaConfiguracionService', function($localStorage, focaConfiguracionService) { | |
| 2 | + .run([ | |
| 3 | + '$localStorage', | |
| 4 | + 'focaConfiguracionService', | |
| 5 | + '$cookies', | |
| 6 | + function($localStorage, focaConfiguracionService, $cookies) { | |
| 3 | 7 | if (!$localStorage.terminalKey) { |
| 4 | 8 | focaConfiguracionService.getHashTerminal().then(function(res) { |
| 9 | + | |
| 5 | 10 | $localStorage.terminalKey = res.data; |
| 11 | + | |
| 6 | 12 | }); |
| 7 | 13 | } |
| 14 | + | |
| 15 | + if(!$cookies.get('puntoVenta') && $localStorage.terminalKey) { | |
| 16 | + focaConfiguracionService.getPuntoVenta().then(function(res) { | |
| 17 | + | |
| 18 | + $cookies.put('puntoVenta', res.data); | |
| 19 | + }); | |
| 20 | + } | |
| 21 | + | |
| 8 | 22 | }]); |
src/js/config.js
src/js/requestHeadersInterceptor.js
| ... | ... | @@ -5,13 +5,15 @@ angular.module('focaConfiguracion') |
| 5 | 5 | request: function(config) { |
| 6 | 6 | |
| 7 | 7 | var nombreUsuario = $cookies.get('nombreUsuario'); |
| 8 | + var puntoVenta = $cookies.get('puntoVenta'); | |
| 8 | 9 | |
| 9 | 10 | config.headers["X-Terminal-Key"] = $localStorage.terminalKey; |
| 10 | - config.headers["Nombre-Usuario"] = nombreUsuario; | |
| 11 | + config.headers["X-Nombre-Usuario"] = nombreUsuario; | |
| 12 | + config.headers["X-Punto-Venta"] = puntoVenta; | |
| 11 | 13 | return config; |
| 12 | 14 | } |
| 13 | 15 | } |
| 14 | 16 | |
| 15 | 17 | return request; |
| 16 | 18 | } |
| 17 | - ]); | |
| 18 | 19 | \ No newline at end of file |
| 20 | + ]); |
src/js/service.js
| ... | ... | @@ -5,6 +5,9 @@ angular.module('focaConfiguracion') |
| 5 | 5 | return { |
| 6 | 6 | getHashTerminal: function() { |
| 7 | 7 | return $http.get(API_ENDPOINT.ENDPOINT_BASE + '/terminal/obtener'); |
| 8 | + }, | |
| 9 | + getPuntoVenta: function() { | |
| 10 | + return $http.get(API_ENDPOINT.URL + '/config/punto-venta'); | |
| 8 | 11 | } |
| 9 | 12 | } |
| 10 | 13 | } |