Blame view

app/views/login/login.service.js 1.39 KB
5c6477d3d   Rishav   Admin Acufuel set...
1
2
3
4
5
6
7
8
9
10
11
12
13
  (function() {
    'use strict';
  
    angular.module('inspinia')
        .service('LoginService', ['$rootScope', '$q', '$http', 'BE', LoginService])
  
     function LoginService($rootScope, $q, $http, BE) {
  
          this.loginUser = function(data) {
  
            var deferred = $q.defer();
            $http({
                method : 'POST',
0a4eb77cc   Rishav   FBO admin impleme...
14
                url : BE.url +'/login',
5c6477d3d   Rishav   Admin Acufuel set...
15
16
17
18
                headers : {'Content-Type': 'application/x-www-form-urlencoded'},
                data : data
            })
            .success(function(result) {
0a4eb77cc   Rishav   FBO admin impleme...
19
                deferred.resolve(result.data);
5c6477d3d   Rishav   Admin Acufuel set...
20
21
22
            })
            return deferred.promise;
          }
0a4eb77cc   Rishav   FBO admin impleme...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  
          this.authenticate = function() {
              var deferred = $q.defer();
              $http({
                 method : 'GET',
                 url : BE.url+'user/authenticate',
                 headers : {'Content-Type': 'application/x-www-form-urlencoded'}
              }).then(function (result){
                  console.log(result)
                  localStorage.setItem('userProfileId', result.data.userProfile.id);
                  localStorage.setItem('email', result.data.userProfile.email);
                  deferred.resolve(result.data);
              },function (result){
                  deferred.resolve(result.data);
              });
              return deferred.promise;
          }
  
          this.setAuth = function(data) {
              localStorage.setItem('loginStatus', data);
          }
5c6477d3d   Rishav   Admin Acufuel set...
44
45
46
     }
  
  })();