Use anonymous function as interceptor.

This commit is contained in:
Alexis Lahouze 2017-07-08 00:17:15 +02:00
parent d6eb6781c6
commit 9a7d3938aa

View File

@ -74,8 +74,10 @@ module.exports = angular.module('accountant.login', [
}; };
}) })
.factory('sessionInjector', function($storage) { .config(function($httpProvider, $storageProvider) {
var sessionInjector = { // Define interceptors.
$httpProvider.interceptors.push(function($storage) {
return {
request: function(config) { request: function(config) {
var access_token = $storage.session.get('access_token'); var access_token = $storage.session.get('access_token');
@ -87,15 +89,9 @@ module.exports = angular.module('accountant.login', [
} }
return config; return config;
} },
}; };
});
return sessionInjector;
})
.config(function($httpProvider, $storageProvider) {
// Define interceptors.
$httpProvider.interceptors.push('sessionInjector');
// Configure storage // Configure storage
// Set global prefix for stored keys // Set global prefix for stored keys