Skip to content

Cleanup timers when OAuthService is destroyed #463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, NgZone, Optional } from '@angular/core';
import { Injectable, NgZone, Optional, OnDestroy } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable, Subject, Subscription, of, race } from 'rxjs';
import { filter, take, delay, first, tap, map } from 'rxjs/operators';
Expand Down Expand Up @@ -33,7 +33,7 @@ import { WebHttpUrlEncodingCodec } from './encoder';
* password flow.
*/
@Injectable()
export class OAuthService extends AuthConfig {
export class OAuthService extends AuthConfig implements OnDestroy {
// Extending AuthConfig ist just for LEGACY reasons
// to not break existing code.

Expand Down Expand Up @@ -1780,6 +1780,14 @@ export class OAuthService extends AuthConfig {
});
}

/**
* @ignore
*/
public ngOnDestroy() {
this.clearAccessTokenTimer();
this.clearIdTokenTimer();
}

protected createNonce(): Promise<string> {
return new Promise((resolve, reject) => {
if (this.rngUrl) {
Expand Down