Skip to content

Instantly share code, notes, and snippets.

@jvans1
Last active December 28, 2020 18:38
Show Gist options
  • Save jvans1/10119641 to your computer and use it in GitHub Desktop.
Save jvans1/10119641 to your computer and use it in GitHub Desktop.
Angular Auth Service
angular.module('myApp', []).factory( 'AuthService', ["$cookieStore", '$http',
var currentUser;
return {
login: function(email, password, fn) {
currentUser = //Login work with $http
$cookieStore.put("currentUser", currentUser.name)
},
logout: function(){
//Logout work with $http
currentUser = undefined
$cookieStore.put("currentUser", currentUser)
},
isLoggedIn: function(){
return currentUser !== undefined
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment