Commit a957e21431cc1ae3dd78e087e2ba465526d0e656

Authored by Nicolás Guarnieri
1 parent 32eadf8739
Exists in master and in 2 other branches demo, develop

fix login

Showing 2 changed files with 7 additions and 5 deletions   Show diff stats
src/js/controller.js
... ... @@ -6,16 +6,16 @@ angular.module('focaLogin')
6 6 $scope.enviar = function() {
7 7 focaLoginService.login($scope.usuario).then(function(datos) {
8 8  
9   - if (datos.data.chofer.id) {
  9 + if (datos.data.chofer && datos.data.chofer.id) {
10 10 $cookies.put('chofer', datos.data.chofer.id);
11   - } else if (datos.data.vendedorCobrador.CodVen) {
  11 + } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.CodVen) {
12 12 $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen);
13 13 } else {
14 14 focaModalService.alert('Existe un error con el usuario ingresado');
15 15 return;
16 16 }
17 17  
18   -
  18 + console.info(datos.data);
19 19 $cookies.put('token', datos.data.token);
20 20 $location.path('/');
21 21 $scope.$emit('blur');
... ... @@ -4,11 +4,13 @@ angular.module('focaLogin')
4 4 function($http, API_ENDPOINT, APP, $cookies) {
5 5 return {
6 6 login: function(usuario) {
  7 + var param = '';
  8 +
7 9 if (APP) {
8   - APP = '/' + APP;
  10 + param = '/' + APP;
9 11 }
10 12  
11   - return $http.post(API_ENDPOINT.URL + '/usuario/login' + APP , usuario);
  13 + return $http.post(API_ENDPOINT.URL + '/usuario/login' + param , usuario);
12 14 },
13 15 getLoginData: function() {
14 16 if ($cookies.get('chofer')) {