Created
July 30, 2015 18:47
-
-
Save jcdalton2201/75c1ad822ca0875372ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular.module('ls2FrontEnd') | |
.factory('USDLongTokenInterceptor', USDLongTokenInterceptor); | |
USDLongTokenInterceptor.$inject = ['authTokenFactory','$rootScope','$q']; | |
function USDLongTokenInterceptor (authTokenFactory, $rootScope, $q) { | |
var meaningOfLife = 42; | |
var factory = { | |
request: request, | |
// requestError: requestError, | |
// response: response, | |
responseError: responseError | |
}; | |
return factory; | |
function request(config) { | |
var token = authTokenFactory.getToken(); | |
config.headers.Authorization = 'UDSLongToken '+ token; | |
return config; | |
} | |
function responseError (response){ | |
if(response.status > 400 && response.status < 500){ | |
$rootScope.$broadcast('LS:Unauthorized',{url: response.config.url}); | |
} | |
return $q.reject(response); | |
} | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment