Created
February 5, 2014 06:03
-
-
Save prettymuchbryce/8818148 to your computer and use it in GitHub Desktop.
This file contains 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
app.factory('userService', ['$q', '$timeout', '$http', '$rootScope', function($q, $timeout, $http, $rootScope) { | |
var userService = {}; | |
userService.tryLoginFromCookie = function() { | |
var promise = $q.defer(); | |
$http({method: 'POST', url: '/login'}). | |
success(function(data, status, headers, config) { | |
$timeout(function() { | |
$rootScope.$broadcast('login', data); | |
}); | |
}). | |
error(function(data, status, headers, config) { | |
console.log("Error"); | |
// called asynchronously if an error occurs | |
// or server returns response with an error status. | |
}); | |
return promise; | |
}; | |
userService.login = function() { | |
}; | |
userService.register = function() { | |
}; | |
userService.logout = function() { | |
}; | |
return userService; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment