Skip to content

Commit ba925c1

Browse files
committed
Remove deprecated RouterState.queryParam
1 parent 25486ac commit ba925c1

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## v0.1.3
4+
**Bugfixes:**
5+
- Removes deprecated RouterState.queryParam for ActivatedRoute.params (fixes [#5](https://github.com/neroniaky/angular2-token/issues/5))
6+
37
## v0.1.2
48
**Features:**
59
- Added `requestOptions` to parameter to all HTTP wrapper methods

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Angular2-Token is currently in Alpha. Any contribution is much appreciated.
1414
## Live Demo
1515
You can try out Angular2-Token [here](https://angular2-token.herokuapp.com/).
1616

17+
The repository can be found [here](https://github.com/neroniaky/angular2-token-example).
18+
1719
## Content
1820
- [Installation](#installation)
1921
- [Configuration](#configuration)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-token",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Angular2 service for token based authentication",
55
"main": "./angular2-token.js",
66
"typings": "./angular2-token.d.ts",

src/angular2-token.service.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
RequestMethod,
88
RequestOptions
99
} from '@angular/http';
10-
import { Router } from '@angular/router';
10+
import { ActivatedRoute } from '@angular/router';
1111
import { Observable } from 'rxjs/Observable';
1212
import 'rxjs/add/operator/share';
1313

@@ -38,7 +38,7 @@ export class Angular2TokenService {
3838

3939
constructor(
4040
private _http: Http,
41-
private _router: Router
41+
private _activatedRoute: ActivatedRoute
4242
) { }
4343

4444
// Inital configuration
@@ -284,20 +284,20 @@ export class Angular2TokenService {
284284
// Try to get auth data from url parameters.
285285
private _getAuthDataFromParams() {
286286

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
289288

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;
297290

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;
301301
}
302302
}
303303

src/angular2-token.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Http, BaseRequestOptions, Response, ResponseOptions, Headers, RequestMe
22
import { MockBackend } from '@angular/http/testing';
33
import { provide } from '@angular/core';
44
import { inject, addProviders } from '@angular/core/testing';
5-
import { Router, ActivatedRoute, RouterOutletMap, RouterState } from '@angular/router';
5+
import { ActivatedRoute, RouterOutletMap, RouterState } from '@angular/router';
66

77
import { Angular2TokenService } from './';
88

@@ -46,7 +46,7 @@ describe('Angular2TokenService', () => {
4646
addProviders([
4747
BaseRequestOptions,
4848
MockBackend,
49-
{ provide: Router, useClass: Mock },
49+
{ provide: ActivatedRoute, useClass: Mock },
5050
{
5151
provide: Http,
5252
useFactory: (backend, defaultOptions) => { return new Http(backend, defaultOptions) },

0 commit comments

Comments
 (0)