Skip to content

Instantly share code, notes, and snippets.

@pareshchouhan
Created October 11, 2014 19:38
Show Gist options
  • Select an option

  • Save pareshchouhan/786943c07cd9522bf6df to your computer and use it in GitHub Desktop.

Select an option

Save pareshchouhan/786943c07cd9522bf6df to your computer and use it in GitHub Desktop.
bets4you.factory('AuthService',['$http','$window','$location',function($http,$window,$location){
this.userInfo = null;
this.steamID64 = null;
this.auth = false;
function init() {
if ($window.sessionStorage["userInfo"]) {
this.userInfo = JSON.parse($window.sessionStorage["userInfo"]);
}
}
function logout() {
$http({
method: "POST",
url: '/logout',
headers: {
"id": id
}
}).then(function(result) {
$window.sessionStorage["userInfo"] = null;
userInfo = null;
}, function(error) {
});
}
function login() {
if($window.sessionStorage["userInfo"] == null) {
$window.sessionStorage["userInfo"] = $location.path();
this.steamID64 = $window.location;
this.auth = true;
}
}
init();
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment