Skip to content

Instantly share code, notes, and snippets.

@andyczerwonka
Created January 29, 2015 23:03
Show Gist options
  • Save andyczerwonka/adf198edc329b66c4890 to your computer and use it in GitHub Desktop.
Save andyczerwonka/adf198edc329b66c4890 to your computer and use it in GitHub Desktop.
var authToken = localStorageService.get('authToken');
$http.defaults.headers.common.Authorization = 'auth-token ' + authToken;
$http.get('/api/whoami').success(function(data) {
self.user = data;
}).error(function() {
self.user = null;
$location.path('/login');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment