Skip to content

Instantly share code, notes, and snippets.

@jvans1
Created May 25, 2013 16:49
Show Gist options
  • Save jvans1/5649758 to your computer and use it in GitHub Desktop.
Save jvans1/5649758 to your computer and use it in GitHub Desktop.
app.factory( 'AuthService', function($http, $location, $rootScope) {
return {
login: function(email, password) {
currentUser = $http({method: "POST", url: "/login", params: {email: email, password: password}}).
success(function(data, status){
$rootScope.current_user = data.user
return $location.path("/feed");
}).
error(function(data, status){
return $location.path("/login");
});
},
logout: function() { },
isLoggedIn: function() {
$rootScope.current_user !== undefined
},
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment