Skip to content

Commit 92d0cf7

Browse files
committed
Added UserData Typings, README fix #39
1 parent 3a18d5c commit 92d0cf7

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ this.sendHttpRequest(new RequestOptions({
268268
## Multiple User Types
269269
An array of `UserType` can be passed in `Angular2TokenOptions` during `init()`.
270270
The user type is selected during sign in and persists until sign out.
271-
`.currentUser` returns the currently logged in user.
271+
`.currentUserType` returns the currently logged in user.
272272
273273
#### Example:
274274
```javascript
@@ -285,7 +285,7 @@ this._tokenService.signIn(
285285
'ADMIN'
286286
)
287287
288-
this._tokenService.currentUser; // ADMIN
288+
this._tokenService.currentUserType; // ADMIN
289289
```
290290
291291
## Route Guards

src/angular2-token.model.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
export interface UserType {
2-
name: string;
3-
path: string;
4-
}
5-
61
export interface AuthData {
72
accessToken: string;
83
client: string;
@@ -11,8 +6,25 @@ export interface AuthData {
116
uid: string;
127
}
138

9+
export interface UserData {
10+
id: number;
11+
provider: string;
12+
uid: string;
13+
name: string;
14+
nickname: string;
15+
image: any;
16+
email: string;
17+
}
18+
19+
// Configuration Options
20+
21+
export interface UserType {
22+
name: string;
23+
path: string;
24+
}
25+
1426
export interface OAuthPaths {
15-
github?: string;
27+
github?: string;
1628
}
1729

1830
export interface Angular2TokenOptions {

src/angular2-token.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'rxjs/add/operator/share';
1414

1515
import {
1616
UserType,
17+
UserData,
1718
AuthData,
1819
Angular2TokenOptions
1920
} from './angular2-token.model';
@@ -28,14 +29,14 @@ export class Angular2TokenService implements CanActivate {
2829
return null;
2930
}
3031

31-
get currentUserData(): string {
32+
get currentUserData(): UserData {
3233
return this._currentUserData;
3334
}
3435

3536
private _options: Angular2TokenOptions;
3637
private _currentUserType: UserType;
3738
private _currentAuthData: AuthData;
38-
private _currentUserData: any;
39+
private _currentUserData: UserData;
3940

4041
constructor(
4142
private _http: Http,

0 commit comments

Comments
 (0)