|
7 | 7 | RequestMethod, |
8 | 8 | RequestOptions |
9 | 9 | } from '@angular/http'; |
10 | | -import { Router } from '@angular/router'; |
| 10 | +import { ActivatedRoute } from '@angular/router'; |
11 | 11 | import { Observable } from 'rxjs/Observable'; |
12 | 12 | import 'rxjs/add/operator/share'; |
13 | 13 |
|
@@ -38,7 +38,7 @@ export class Angular2TokenService { |
38 | 38 |
|
39 | 39 | constructor( |
40 | 40 | private _http: Http, |
41 | | - private _router: Router |
| 41 | + private _activatedRoute: ActivatedRoute |
42 | 42 | ) { } |
43 | 43 |
|
44 | 44 | // Inital configuration |
@@ -284,20 +284,20 @@ export class Angular2TokenService { |
284 | 284 | // Try to get auth data from url parameters. |
285 | 285 | private _getAuthDataFromParams() { |
286 | 286 |
|
287 | | - if (this._router.routerState != null) { // Fix for Testing, has to be removed later |
288 | | - this._router.routerState.queryParams.subscribe(params => { |
| 287 | + if (this._activatedRoute.params != null) { // Fix for Testing, has to be removed later |
289 | 288 |
|
290 | | - let authData: AuthData = { |
291 | | - accessToken: params['token'], |
292 | | - client: params['client_id'], |
293 | | - expiry: params['expiry'], |
294 | | - tokenType: 'Bearer', |
295 | | - uid: params['uid'] |
296 | | - }; |
| 289 | + let params = this._activatedRoute.params; |
297 | 290 |
|
298 | | - if (this._checkIfComplete(authData)) |
299 | | - this._currentAuthData = authData; |
300 | | - }); |
| 291 | + let authData: AuthData = { |
| 292 | + accessToken: params['token'], |
| 293 | + client: params['client_id'], |
| 294 | + expiry: params['expiry'], |
| 295 | + tokenType: 'Bearer', |
| 296 | + uid: params['uid'] |
| 297 | + }; |
| 298 | + |
| 299 | + if (this._checkIfComplete(authData)) |
| 300 | + this._currentAuthData = authData; |
301 | 301 | } |
302 | 302 | } |
303 | 303 |
|
|
0 commit comments