|
1 |
| -import { Injectable, Optional } from '@angular/core'; |
| 1 | +import { Injectable, NgZone, Optional } from '@angular/core' |
2 | 2 | import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
3 | 3 | import { Observable } from 'rxjs/Observable';
|
4 | 4 | import { Subject } from 'rxjs/Subject';
|
@@ -67,6 +67,7 @@ export class OAuthService
|
67 | 67 | private inImplicitFlow = false;
|
68 | 68 |
|
69 | 69 | constructor(
|
| 70 | + private ngZone: NgZone, |
70 | 71 | private http: HttpClient,
|
71 | 72 | @Optional() storage: OAuthStorage,
|
72 | 73 | @Optional() tokenValidationHandler: ValidationHandler,
|
@@ -262,26 +263,42 @@ export class OAuthService
|
262 | 263 | private setupAccessTokenTimer(): void {
|
263 | 264 | let expiration = this.getAccessTokenExpiration();
|
264 | 265 | let storedAt = this.getAccessTokenStoredAt();
|
265 |
| - let timeout = this.calcTimeout(storedAt, expiration); |
266 |
| - |
267 |
| - this.accessTokenTimeoutSubscription = |
268 |
| - Observable |
269 |
| - .of(new OAuthInfoEvent('token_expires', 'access_token')) |
270 |
| - .delay(timeout) |
271 |
| - .subscribe(e => this.eventsSubject.next(e)); |
| 266 | + // let timeout = this.calcTimeout(storedAt, expiration); |
| 267 | + let timeout = 5000; |
| 268 | + |
| 269 | + this.ngZone.runOutsideAngular(() => { |
| 270 | + this.accessTokenTimeoutSubscription = |
| 271 | + Observable |
| 272 | + .of(new OAuthInfoEvent('token_expires', 'access_token')) |
| 273 | + .delay(timeout) |
| 274 | + .subscribe(e => { |
| 275 | + this.ngZone.run(() => { |
| 276 | + console.log('setupAccessTokenTimer') |
| 277 | + this.eventsSubject.next(e); |
| 278 | + }) |
| 279 | + }); |
| 280 | + }) |
272 | 281 | }
|
273 | 282 |
|
274 | 283 |
|
275 | 284 | private setupIdTokenTimer(): void {
|
276 | 285 | let expiration = this.getIdTokenExpiration();
|
277 | 286 | let storedAt = this.getIdTokenStoredAt();
|
278 |
| - let timeout = this.calcTimeout(storedAt, expiration); |
279 |
| - |
280 |
| - this.idTokenTimeoutSubscription = |
281 |
| - Observable |
282 |
| - .of(new OAuthInfoEvent('token_expires', 'id_token')) |
283 |
| - .delay(timeout) |
284 |
| - .subscribe(e => this.eventsSubject.next(e)); |
| 287 | + // let timeout = this.calcTimeout(storedAt, expiration); |
| 288 | + let timeout = 5000; |
| 289 | + |
| 290 | + this.ngZone.runOutsideAngular(() => { |
| 291 | + this.idTokenTimeoutSubscription = |
| 292 | + Observable |
| 293 | + .of(new OAuthInfoEvent('token_expires', 'id_token')) |
| 294 | + .delay(timeout) |
| 295 | + .subscribe(e => { |
| 296 | + this.ngZone.run(() => { |
| 297 | + console.log('setupIdTokenTimer') |
| 298 | + this.eventsSubject.next(e); |
| 299 | + }) |
| 300 | + }); |
| 301 | + }) |
285 | 302 | }
|
286 | 303 |
|
287 | 304 | private clearAccessTokenTimer(): void {
|
|
0 commit comments