Skip to content

Commit d49021a

Browse files
Merge pull request #630 from l1b3r/setupRefreshTimer
Unsubscribe from 'token_received' events before re-subscribing
2 parents b2837cd + 3214937 commit d49021a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

projects/lib/src/oauth-service.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
7575
protected _storage: OAuthStorage;
7676
protected accessTokenTimeoutSubscription: Subscription;
7777
protected idTokenTimeoutSubscription: Subscription;
78+
protected tokenReceivedSubscription: Subscription;
7879
protected sessionCheckEventListener: EventListener;
7980
protected jwksUri: string;
8081
protected sessionCheckTimer: any;
@@ -317,7 +318,10 @@ export class OAuthService extends AuthConfig implements OnDestroy {
317318
this.setupExpirationTimers();
318319
}
319320

320-
this.events.pipe(filter(e => e.type === 'token_received')).subscribe(_ => {
321+
if (this.tokenReceivedSubscription)
322+
this.tokenReceivedSubscription.unsubscribe();
323+
324+
this.tokenReceivedSubscription = this.events.pipe(filter(e => e.type === 'token_received')).subscribe(_ => {
321325
this.clearAccessTokenTimer();
322326
this.clearIdTokenTimer();
323327
this.setupExpirationTimers();

0 commit comments

Comments
 (0)