summaryrefslogtreecommitdiffstats
path: root/app/services/users.service.js
blob: e780c38fe6308a5a077d5b1f23ba64572c025f1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function () {

    'use strict';

    angular.module('dcaeApp.services.users', [])

        .service('usersService', ['$http', '$q', 'cacheService', function ($http, $q, cacheService) {

            var urls = cacheService.get("configuration").urls;

            this.login = function (postData) {
                var deferred = $q.defer();
                $http.post(urls.auth.login, postData).success(function (data, status, headers, config) {
                    deferred.resolve({data: data, status: status});
                }).error(function (data, status, headers, config) {
                    deferred.reject({message: data, status: status});
                });
                return deferred.promise;
            };

            this.register = function (postData) {
                var deferred = $q.defer();
                $http.post(urls.auth.register, postData).success(function (data, status, headers, config) {
                    deferred.resolve({data: data, status: status});
                }).error(function (data, status, headers, config) {
                    deferred.reject({message: data, status: status});
                });
                return deferred.promise;
            };

        }]);

})();