1
1
import { Injectable , NgZone , Optional , OnDestroy , Inject } from '@angular/core' ;
2
- import { HttpClient , HttpHeaders , HttpParams } from '@angular/common/http' ;
2
+ import { HttpClient , HttpHeaders , HttpParams , HttpErrorResponse } from '@angular/common/http' ;
3
3
import {
4
4
Observable ,
5
5
Subject ,
6
6
Subscription ,
7
7
of ,
8
8
race ,
9
9
from ,
10
- combineLatest
10
+ combineLatest ,
11
+ throwError
11
12
} from 'rxjs' ;
12
13
import {
13
14
filter ,
@@ -16,7 +17,8 @@ import {
16
17
tap ,
17
18
map ,
18
19
switchMap ,
19
- debounceTime
20
+ debounceTime ,
21
+ catchError
20
22
} from 'rxjs/operators' ;
21
23
import { DOCUMENT } from '@angular/common' ;
22
24
@@ -2296,9 +2298,10 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2296
2298
* @param noRedirectToLogoutUrl
2297
2299
* @param state
2298
2300
*/
2301
+ public logOut ( ) : void ;
2299
2302
public logOut ( customParameters : object ) : void ;
2300
2303
public logOut ( noRedirectToLogoutUrl : boolean , state : string ) : void ;
2301
- public logOut ( customParameters : boolean | object , state = '' ) : void {
2304
+ public logOut ( customParameters : boolean | object = { } , state = '' ) : void {
2302
2305
let noRedirectToLogoutUrl = false ;
2303
2306
if ( typeof customParameters === 'boolean' ) {
2304
2307
noRedirectToLogoutUrl = customParameters ;
@@ -2576,7 +2579,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2576
2579
* of the token issued allowing the authorization server to clean
2577
2580
* up any security credentials associated with the authorization
2578
2581
*/
2579
- public revokeTokenAndLogout ( ) : Promise < any > {
2582
+ public revokeTokenAndLogout ( customParameters : object = { } , ignoreCorsIssues = false ) : Promise < any > {
2580
2583
let revokeEndpoint = this . revocationEndpoint ;
2581
2584
let accessToken = this . getAccessToken ( ) ;
2582
2585
let refreshToken = this . getRefreshToken ( ) ;
@@ -2641,9 +2644,27 @@ export class OAuthService extends AuthConfig implements OnDestroy {
2641
2644
revokeRefreshToken = of ( null ) ;
2642
2645
}
2643
2646
2647
+ if ( ignoreCorsIssues ) {
2648
+ revokeAccessToken = revokeAccessToken
2649
+ . pipe ( catchError ( ( err : HttpErrorResponse ) => {
2650
+ if ( err . status === 0 ) {
2651
+ return of < void > ( ) ;
2652
+ }
2653
+ return throwError ( err ) ;
2654
+ } ) ) ;
2655
+
2656
+ revokeRefreshToken = revokeRefreshToken
2657
+ . pipe ( catchError ( ( err : HttpErrorResponse ) => {
2658
+ if ( err . status === 0 ) {
2659
+ return of < void > ( ) ;
2660
+ }
2661
+ return throwError ( err ) ;
2662
+ } ) ) ;
2663
+ }
2664
+
2644
2665
combineLatest ( [ revokeAccessToken , revokeRefreshToken ] ) . subscribe (
2645
2666
res => {
2646
- this . logOut ( ) ;
2667
+ this . logOut ( )
2647
2668
resolve ( res ) ;
2648
2669
this . logger . info ( 'Token successfully revoked' ) ;
2649
2670
} ,
0 commit comments