'use strict';
angular.module('MetronicApp').factory('loginService', function ($http, $state, sessionService, PostSv, $rootScope, GetSv) {
    return{
        login: function (data, scope) {

            PostSv.postData('login', data)
                    .then(function (data) {
                        if (data.Error) {
                            scope.msgtxt = data.Error;
                        } else {
                            sessionService.set('uid', data.id_usuario);
                            if (data.rol === 'MECANICO') {
                                $state.go("main.horimetro");
                            } else {
                                $state.go("main.home");
                            }
                            $rootScope.user = data;
                        }
                    },function(e){
                        console.log(e);
                    });

        },
        logout: function () {
            sessionService.destroy('uid');
            GetSv.getData('logOut').then(function (data) {
                if (data.Estado === true) {
                    $state.go("login");
                } else {
                    alert("Error");
                }
            });

        },
        islogged: function () {
            var b = false;
            if(sessionService.get('uid'))
                b = true;
//            PostSv.postData('check').then(function (data) {
//                b = data.Estado;
//            });
            return b;
        },
        verifySession: function(){
            if(isLogged()){
                $state.go('main.home');
            }else{
                $state.go('login');
            }
        }
        ,
        getUser: function () {
            var uid = sessionService.get('uid');
            GetSv.getDataParam('getUser', {usuario: uid})
                    .then(function (data) {
                        if (data.Error) {
                        } else {
                            $rootScope.user = data;
                        }

                    });
        }
    };

});


@@ -377,16 +377,82 @@
 Error;%0D%0A
+                            console.log(%22asdasd %22 + data.Error);%0D%0A
         
@@ -469,32 +469,32 @@
       %7D else %7B%0D%0A
-
                 
@@ -900,24 +900,25 @@
       %7D,
+ 
 function
 (e)%7B%0D%0A  
@@ -909,19 +909,21 @@
 function
+ 
 (e)
+ 
 %7B%0D%0A     
@@ -1406,16 +1406,17 @@
       if
+ 
 (session
@@ -1647,18 +1647,20 @@
 function
+ 
 ()
+ 
 %7B%0D%0A     
@@ -1668,16 +1668,17 @@
       if
+ 
 (isLogge
@@ -1681,16 +1681,17 @@
 ogged())
+ 
 %7B%0D%0A     
@@ -1739,20 +1739,22 @@
        %7D
+ 
 else
+ 
 %7B%0D%0A     

Prueba login