Skip to content

Commit 323cdbe

Browse files
author
Leonardo Chaia
committed
Cleanup timers when OAuthService is destroyed
1 parent 0274cf5 commit 323cdbe

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

projects/lib/src/oauth-service.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, NgZone, Optional } from '@angular/core';
1+
import { Injectable, NgZone, Optional, OnDestroy } from '@angular/core';
22
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
33
import { Observable, Subject, Subscription, of, race } from 'rxjs';
44
import { filter, take, delay, first, tap, map } from 'rxjs/operators';
@@ -33,7 +33,7 @@ import { WebHttpUrlEncodingCodec } from './encoder';
3333
* password flow.
3434
*/
3535
@Injectable()
36-
export class OAuthService extends AuthConfig {
36+
export class OAuthService extends AuthConfig implements OnDestroy {
3737
// Extending AuthConfig ist just for LEGACY reasons
3838
// to not break existing code.
3939

@@ -1780,6 +1780,14 @@ export class OAuthService extends AuthConfig {
17801780
});
17811781
}
17821782

1783+
/**
1784+
* @ignore
1785+
*/
1786+
public ngOnDestroy() {
1787+
this.clearAccessTokenTimer();
1788+
this.clearIdTokenTimer();
1789+
}
1790+
17831791
protected createNonce(): Promise<string> {
17841792
return new Promise((resolve, reject) => {
17851793
if (this.rngUrl) {

0 commit comments

Comments
 (0)