AuthenticationService.js 2.66 KB
AIA.factory('AuthenticationService', function ($http, $q) {
    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(status);
            });
            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(status);
        });
            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(status);
            });
            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(status);
            });
            return deferred.promise;
        }

    }
});