@@ -30,13 +30,18 @@ The repository can be found [here](https://github.com/neroniaky/angular2-token-e
30
30
- [ ` .updatePassword() ` ] ( #updatepassword )
31
31
- [ ` .resetPassword() ` ] ( #resetpassword )
32
32
- [ HTTP Service Wrapper] ( #http-service-wrapper )
33
- - [ ` .sendHttpRequest() ` ] ( #sendhttprequest )
34
33
- [ Multiple User Types] ( #multiple-user-types )
35
34
- [ Route Guards] ( #route-guards )
36
- - [ Testing] ( #testing )
35
+ - [ Advanced Usage] ( #advanced-usage )
36
+ - [ ` .sendHttpRequest() ` ] ( #sendhttprequest )
37
+ - [ ` .userSignedIn() ` ] ( #usersignedin )
38
+ - [ ` .currentUserType ` ] ( #currentusertype )
39
+ - [ ` .currentUserData ` ] ( #currentuserdata )
40
+ - [ ` .currentAuthData ` ] ( #currentauthdata )
37
41
- [ Development] ( #development )
38
- - [ Credits] ( #credits )
39
- - [ License] ( #license )
42
+ - [ Testing] ( #testing )
43
+ - [ Credits] ( #credits )
44
+ - [ License] ( #license )
40
45
41
46
## Installation
42
47
1 . Install Angular2-Token via NPM with
@@ -263,21 +268,6 @@ this._tokenService.get('my-resource/1').map(res => res.json()).subscribe(
263
268
);
264
269
` ` `
265
270
266
- # ## .sendHttpRequest()
267
- More customized requests can be send with the ` .sendHttpRequest()` -function. It accepts the RequestOptions-Class.
268
- More information can be found in the Angular2 API Reference [here](https://angular.io/docs/ts/latest/api/http/index/RequestOptions-class.html).
269
-
270
- ` sendHttpRequest(options: RequestOptions): Observable< Response> `
271
-
272
- # ### Example:
273
- ` ` ` javascript
274
- this.sendHttpRequest(new RequestOptions({
275
- method: RequestMethod.Post,
276
- url: ' my-resource/1' ,
277
- data: mydata
278
- }));
279
- ` ` `
280
-
281
271
# # Multiple User Types
282
272
An array of ` UserType` can be passed in ` Angular2TokenOptions` during ` init()` .
283
273
The user type is selected during sign in and persists until sign out.
@@ -320,11 +310,45 @@ const routerConfig: Routes = [
320
310
];
321
311
` ` `
322
312
323
- # # Testing
324
- ` ` ` bash
325
- npm test
313
+ # # Advanced Usage
314
+ More advanced methods can be used if a higher degree of customization is required.
315
+
316
+ # ## .sendHttpRequest()
317
+ More customized requests can be send with the `.sendHttpRequest ()` -function. It accepts the RequestOptions-Class.
318
+ More information can be found in the Angular2 API Reference [here](https://angular.io/docs/ts/latest/api/http/index/RequestOptions-class.html).
319
+
320
+ ` sendHttpRequest(options: RequestOptions): Observable< Response> `
321
+
322
+ # ### Example:
323
+ ` ` ` javascript
324
+ this.sendHttpRequest(new RequestOptions({
325
+ method: RequestMethod.Post,
326
+ url: ' my-resource/1' ,
327
+ data: mydata
328
+ }));
326
329
` ` `
327
330
331
+ # ## .userSignedIn()
332
+ Returns ` true` if a user is signed in. It does not distinguish between user types.
333
+
334
+ `userSignedIn (): boolean`
335
+
336
+ # ## .currentUserType
337
+ Returns current user type as string like specified in the options.
338
+
339
+ ` get currentUserType (): string`
340
+
341
+ # ## .currentUserData
342
+ Returns current user data as returned by devise token auth.
343
+ This variable is ` null` after page reload until the `.validateToken ()` call is answerd by the backend.
344
+
345
+ ` get currentUserData (): UserData`
346
+
347
+ # ## .currentAuthData
348
+ Returns current authentication data which are used to set auth headers.
349
+
350
+ ` get currentAuthData (): AuthData`
351
+
328
352
# # Development
329
353
If the package is installed from Github specified in the package.json, you need to build the package locally.
330
354
@@ -334,8 +358,13 @@ npm install
334
358
npm run build
335
359
` ` `
336
360
337
- # # Credits
361
+ # ## Testing
362
+ ` ` ` bash
363
+ npm test
364
+ ` ` `
365
+
366
+ # ## Credits
338
367
Test config files based on [Angular2 Webpack Starter](https://github.com/AngularClass/angular2-webpack-starter) by AngularClass
339
368
340
- # # License
369
+ # ## License
341
370
The MIT License (see the [LICENSE](https://github.com/neroniaky/angular2-token/blob/master/LICENSE) file for the full text)
0 commit comments