Last active
August 29, 2015 13:57
-
-
Save RGkevin/9381907 to your computer and use it in GitHub Desktop.
Auth service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| angular.module('whiteLabelApp') | |
| .service('Auth', ['Restangular', function (Restangular) { | |
| // AngularJS will instantiate a singleton by calling "new" on this function | |
| var self = this; | |
| self.login = function(data, success, fail, end) { | |
| return Restangular | |
| .all('auth') | |
| .post(data) | |
| .then(function(response) { | |
| if(angular.isFunction(success)) { | |
| success(response); | |
| } | |
| }, function(error) { | |
| if(angular.isFunction(fail)) { | |
| fail(error.data); | |
| } | |
| }) | |
| .finally(function() { | |
| if(angular.isFunction(end)) { | |
| end(); | |
| } | |
| }); | |
| }; | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment