Blame view

app/views/login/login.service.js 1.39 KB
5c6477d3d   Rishav   Admin Acufuel set...
1
2
  (function() {
    'use strict';
9835dbe3e   Rishav   module name changes
3
    angular.module('acuefuel')
5c6477d3d   Rishav   Admin Acufuel set...
4
5
6
7
8
9
10
11
12
        .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...
13
                url : BE.url +'/login',
5c6477d3d   Rishav   Admin Acufuel set...
14
15
16
17
                headers : {'Content-Type': 'application/x-www-form-urlencoded'},
                data : data
            })
            .success(function(result) {
0a4eb77cc   Rishav   FBO admin impleme...
18
                deferred.resolve(result.data);
5c6477d3d   Rishav   Admin Acufuel set...
19
20
21
            })
            return deferred.promise;
          }
0a4eb77cc   Rishav   FBO admin impleme...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  
          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...
43
44
45
     }
  
  })();