Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cilice/366ce464b31401c65188 to your computer and use it in GitHub Desktop.

Select an option

Save cilice/366ce464b31401c65188 to your computer and use it in GitHub Desktop.
myUserService.getUser = function(){
if(typeof(this.user) != "undefined"){
return this.user;
} else {
var promise = $http.get('/users/me')
.success(function(results, status){
if( (status!= 200) || (typeof(results) == "undefined") ){
alert('logged out!');
location.href = "/index.html";
}
this.user = promise.resolve(results);
return this.user;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment