Skip to content

Instantly share code, notes, and snippets.

@Ollo
Created September 25, 2014 21:45
Show Gist options
  • Save Ollo/8da61cb2e450528dbc6a to your computer and use it in GitHub Desktop.
Save Ollo/8da61cb2e450528dbc6a to your computer and use it in GitHub Desktop.
makes auth token global
// session-service.js
this.setAuth = function(token) {
if (!!token && !localStorage.getItem('Token')) {
setTokenToLocalStore(token);
}
$http.defaults.headers.common.Authorization = token ? "Token " + token : localStorage.getItem("Token");
}
// app-controller.js
// set ze token
sessionService.setAuth();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment