File tree 1 file changed +11
-8
lines changed
1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -161,11 +161,14 @@ export class OAuthService extends AuthConfig {
161
161
* about to expire.
162
162
* @param params Additional parameter to pass
163
163
*/
164
- public setupAutomaticSilentRefresh ( params : object = { } ) {
164
+ public setupAutomaticSilentRefresh ( params : object = { } , listenTo ?: 'access_token' | 'id_token' | 'any' ) {
165
165
this . events . pipe ( filter ( e => e . type === 'token_expires' ) ) . subscribe ( e => {
166
- this . silentRefresh ( params ) . catch ( _ => {
167
- this . debug ( 'Automatic silent refresh did not work' ) ;
168
- } ) ;
166
+ const event = e as OAuthInfoEvent ;
167
+ if ( listenTo == null || listenTo === 'any' || event . info === listenTo ) {
168
+ this . silentRefresh ( params ) . catch ( _ => {
169
+ this . debug ( 'Automatic silent refresh did not work' ) ;
170
+ } ) ;
171
+ }
169
172
} ) ;
170
173
171
174
this . restartRefreshTimerIfStillLoggedIn ( ) ;
@@ -942,12 +945,12 @@ export class OAuthService extends AuthConfig {
942
945
break ;
943
946
case 'changed' :
944
947
this . ngZone . run ( ( ) => {
945
- this . handleSessionChange ( )
948
+ this . handleSessionChange ( ) ;
946
949
} ) ;
947
950
break ;
948
951
case 'error' :
949
- this . ngZone . run ( ( ) => {
950
- this . handleSessionError ( )
952
+ this . ngZone . run ( ( ) => {
953
+ this . handleSessionError ( ) ;
951
954
} ) ;
952
955
break ;
953
956
}
@@ -1761,7 +1764,7 @@ export class OAuthService extends AuthConfig {
1761
1764
logoutUrl =
1762
1765
this . logoutUrl +
1763
1766
( this . logoutUrl . indexOf ( '?' ) > - 1 ? '&' : '?' ) +
1764
- params . toString ( )
1767
+ params . toString ( ) ;
1765
1768
}
1766
1769
location . href = logoutUrl ;
1767
1770
}
You can’t perform that action at this time.
0 commit comments