diff --git a/src/login/index.js b/src/login/index.js index 897a84d..69f3a63 100644 --- a/src/login/index.js +++ b/src/login/index.js @@ -74,28 +74,24 @@ module.exports = angular.module('accountant.login', [ }; }) - .factory('sessionInjector', function($storage) { - var sessionInjector = { - request: function(config) { - var access_token = $storage.session.get('access_token'); - - if (access_token) { - //var tokenType = $storage.get('token_type'); - var tokenType = 'Bearer'; - var authorization = tokenType + ' ' + access_token; - config.headers.authorization = authorization; - } - - return config; - } - }; - - return sessionInjector; - }) - .config(function($httpProvider, $storageProvider) { // Define interceptors. - $httpProvider.interceptors.push('sessionInjector'); + $httpProvider.interceptors.push(function($storage) { + return { + request: function(config) { + var access_token = $storage.session.get('access_token'); + + if (access_token) { + //var tokenType = $storage.get('token_type'); + var tokenType = 'Bearer'; + var authorization = tokenType + ' ' + access_token; + config.headers.authorization = authorization; + } + + return config; + }, + }; + }); // Configure storage // Set global prefix for stored keys