@@ -12,8 +12,8 @@ angular.module('supportAdminApp')
1212 var refreshingToken = null ;
1313
1414 jwtInterceptorProvider . tokenGetter = [
15- 'AuthService' , '$http' , 'API_URL' , 'ADMIN_TOOL_URL' , 'config' ,
16- function ( $authService , $http , API_URL , ADMIN_TOOL_URL , config ) {
15+ 'AuthService' , '$http' , 'API_URL' , 'ADMIN_TOOL_URL' , 'config' , 'SPIGIT_API_URL' ,
16+ function ( $authService , $http , API_URL , ADMIN_TOOL_URL , config , SPIGIT_API_URL ) {
1717 // token V2 for API V2
1818 if ( config . url . indexOf ( ADMIN_TOOL_URL ) > - 1 ) {
1919 if ( $authService . getTokenV2 ( ) ) {
@@ -24,39 +24,42 @@ angular.module('supportAdminApp')
2424
2525 // token V3 for API V3
2626 } else {
27- var currentToken = $authService . getTokenV3 ( ) ;
27+ if ( config . url . indexOf ( SPIGIT_API_URL ) === - 1 ) {
2828
29- function handleRefreshResponse ( res ) {
30- var newToken , ref , ref1 , ref2 ;
29+ var currentToken = $authService . getTokenV3 ( ) ;
3130
32- newToken = ( ref = res . data ) != null ? ( ref1 = ref . result ) != null ? ( ref2 = ref1 . content ) != null ? ref2 . token : void 0 : void 0 : void 0 ;
31+ function handleRefreshResponse ( res ) {
32+ var newToken , ref , ref1 , ref2 ;
3333
34- $authService . setTokenV3 ( newToken ) ;
34+ newToken = ( ref = res . data ) != null ? ( ref1 = ref . result ) != null ? ( ref2 = ref1 . content ) != null ? ref2 . token : void 0 : void 0 : void 0 ;
3535
36- return newToken ;
37- } ;
36+ $authService . setTokenV3 ( newToken ) ;
3837
39- function refreshingTokenComplete ( ) {
40- return refreshingToken = null ;
41- } ;
38+ return newToken ;
39+ } ;
4240
43- if ( $authService . getTokenV3 ( ) && $authService . isTokenV3Expired ( ) ) {
44- if ( refreshingToken === null ) {
45- refreshingToken = $http ( {
46- method : 'GET' ,
47- url : API_URL + "/v3/authorizations/1" ,
48- headers : {
49- 'Authorization' : "Bearer " + currentToken
50- }
51- } )
52- . then ( handleRefreshResponse ) [ "finally" ] ( refreshingTokenComplete )
53- . catch ( function ( ) {
54- $authService . login ( ) ;
55- } ) ;
41+ function refreshingTokenComplete ( ) {
42+ return refreshingToken = null ;
43+ } ;
44+
45+ if ( $authService . getTokenV3 ( ) && $authService . isTokenV3Expired ( ) ) {
46+ if ( refreshingToken === null ) {
47+ refreshingToken = $http ( {
48+ method : 'GET' ,
49+ url : API_URL + "/v3/authorizations/1" ,
50+ headers : {
51+ 'Authorization' : "Bearer " + currentToken
52+ }
53+ } )
54+ . then ( handleRefreshResponse ) [ "finally" ] ( refreshingTokenComplete )
55+ . catch ( function ( ) {
56+ $authService . login ( ) ;
57+ } ) ;
58+ }
59+ return refreshingToken ;
60+ } else {
61+ return currentToken ;
5662 }
57- return refreshingToken ;
58- } else {
59- return currentToken ;
6063 }
6164 }
6265 } ] ;
0 commit comments