AuthenticationService.js 5.59 KB
AIA.factory('AuthenticationService', function ($http, $q, $rootScope, LoginConstants) {
    return {
        authenticateUser: function (userInfo) {
            var deferred = $q.defer();
            
            $http.post('/API/api/Authenticate', JSON.stringify(userInfo), {
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .success(function (data, status, headers, config) {
                console.log('success')
                deferred.resolve(data);
            }).error(function (data, status, headers, config) {
                console.log('error')
                deferred.reject(data);
                    $rootScope.isVisibleLogin = true;
                    $rootScope.errorMessage = data;
                    $("#messageModal").modal('show');
                
            });
            return deferred.promise;
        },

     validateClientSite: function (clientInfo) {
            var deferred = $q.defer();

         $http.post('/API/api/Client', JSON.stringify(clientInfo), {
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .success(function (data, status, headers, config) {
                console.log('success')
                deferred.resolve(data);
            }).error(function (data, status, headers, config) {
                console.log('error')
                deferred.reject(data);
                $rootScope.isVisibleLogin = true;
                $rootScope.errorMessage = data;
                $("#messageModal").modal('show');

            });
            return deferred.promise;
        },


        SendMailToUser: function (userInfo, havePassword) {
            var deferred = $q.defer();

            $http.post('/API/api/ForgotUser', userInfo, { //JSON.stringify(userEmail)
                headers: {
                    'Content-Type': 'application/json'
                }
            })
        .success(function (data, status, headers, config) {
            console.log('success');
            deferred.resolve(data);
        }).error(function (data, status, headers, config) {
            console.log('error')
            deferred.reject(data);

            $rootScope.isVisibleLogin = true;
            $rootScope.errorMessage = data;
            $("#messageModal").modal('show');
        });
            return deferred.promise;
        },

        ResetUserPassword: function (userInfo) {
            var deferred = $q.defer();

            $http.post('/API/api/ResetPassword', JSON.stringify(userInfo), {
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .success(function (data, status, headers, config) {
                console.log('success')
                deferred.resolve(data);
            }).error(function (data, status, headers, config) {
                console.log('error')
                deferred.reject(data);
                
                $rootScope.isVisibleLogin = true;
                $rootScope.errorMessage = data;
                $("#messageModal").modal('show');
            });
            return deferred.promise;
        },

        UpdateLicenseTerm: function (licenseeAccountNumber) {
            var deferred = $q.defer();

            $http.post('/API/api/LicenseTermCondition', JSON.stringify(licenseeAccountNumber), {
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .success(function (data, status, headers, config) {
                console.log('success')
                deferred.resolve(data);
            }).error(function (data, status, headers, config) {
                console.log('error')
                deferred.reject(data);
               
                $rootScope.isVisibleLogin = true;
                $rootScope.errorMessage = data;
                $("#messageModal").modal('show');
            });
            return deferred.promise;
        },

        UnblockUser: function (userEmailId) {
            var deferred = $q.defer();

            $http.post('/API/api/UnblockUser', JSON.stringify(userEmailId), {
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .success(function (data, status, headers, config) {
                console.log('success')
                deferred.resolve(data);
            }).error(function (data, status, headers, config) {
                console.log('error')
                deferred.reject(data);
               
                $rootScope.isVisibleLogin = true;
                $rootScope.errorMessage = data;
                $("#messageModal").modal('show');
            });
            return deferred.promise;
        },
        getCofigValue: function()
                {         
                    var deferred = $q.defer();
                     $http({
                                 method: 'GET',
                                 url: 'API/api/Configuration/GetConfigurationvalues'
                     }).success(function (data, status, headers, config)
                     {
                         console.log('success' + data);
                         
                                       deferred.resolve(data);
                     }).error(function (data, status, headers, config)
                     {
                                         console.log('error')
                                         deferred.reject(data);

                     });
                                          return deferred.promise;
                  }

           }
});