Commit 1bf6403d2ad1740dea056469cee3bcd8058c4197

Authored by Eric Fernandez
1 parent bef6f00e59
Exists in master

nombre headers

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 }]);
1 1 angular.module('focaConfiguracion')
2 2 .config(['$httpProvider', function($httpProvider) {
3 3 $httpProvider.interceptors.push('RequestHeadersInterceptor');
4   - }]);
5 4 \ No newline at end of file
  5 + }]);
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 + ]);
... ... @@ -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 }