You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Token based authentication service for Angular2 with multiple user support. Angular2-Token works best with the
12
-
[devise token auth](https://github.com/lynndylanhurley/devise_token_auth) gem for Rails.
13
-
10
+
Token based authentication service for Angular2 with multiple user support. Angular2-Token works best with the [devise token auth](https://github.com/lynndylanhurley/devise_token_auth) gem for Rails.
14
11
Angular2-Token is currently in Alpha. Any contribution is much appreciated.
15
12
16
-
## Live Demo
17
13
You can try out Angular2-Token [here](https://angular2-token.herokuapp.com/).
18
14
19
15
The repository can be found [here](https://github.com/neroniaky/angular2-token-example).
20
16
21
-
## Content
22
-
-[Installation](#installation)
23
-
-[Configuration](#configuration)
24
-
-[Service Methods](#methods)
25
-
-[`.signIn()`](#signin)
26
-
-[`.signOut()`](#signout)
27
-
-[`.registerAccount()`](#registeraccount)
28
-
-[`.deleteAccount()`](#deleteaccount)
29
-
-[`.validateToken()`](#validatetoken)
30
-
-[`.updatePassword()`](#updatepassword)
31
-
-[`.resetPassword()`](#resetpassword)
32
-
-[HTTP Service Wrapper](#http-service-wrapper)
33
-
-[Multiple User Types](#multiple-user-types)
34
-
-[Route Guards](#route-guards)
35
-
-[Advanced Usage](#advanced-usage)
36
-
-[`.sendHttpRequest()`](#sendhttprequest)
37
-
-[`.userSignedIn()`](#usersignedin)
38
-
-[`.currentUserType`](#currentusertype)
39
-
-[`.currentUserData`](#currentuserdata)
40
-
-[`.currentAuthData`](#currentauthdata)
41
-
-[Development](#development)
42
-
-[Testing](#testing)
43
-
-[Credits](#credits)
44
-
-[License](#license)
45
-
46
17
## Installation
47
18
1. Install Angular2-Token via NPM with
48
19
```bash
49
20
npm install angular2-token
50
21
```
51
22
52
-
2. Import and add `Angular2TokenService` to your main module. `Angular2TokenService` depends on `HttpModule` and `RouterModule`, so make sure you imported them too.
23
+
2. Import and add `Angular2TokenService` to your main module. `Angular2TokenService` depends on `HttpModule` and `RouterModule`, so make sure you import them too.
53
24
```javascript
54
-
import { HttpModule } from '@angular/http';
55
-
import { RouterModule } from '@angular/router';
56
-
57
25
import { Angular2TokenService } from 'angular2-token';
58
26
59
27
@NgModule({
@@ -75,13 +43,66 @@ The repository can be found [here](https://github.com/neroniaky/angular2-token-e
75
43
}
76
44
```
77
45
78
-
4. If you are using CORS in your Rails API make sure that `Access-Control-Expose-Headers` includes `access-token`, `expiry`, `token-type`, `uid`, and `client`.
79
-
For the rack-cors gem this can be done by adding the following to its config.
80
-
More information can be found [here](https://github.com/lynndylanhurley/devise_token_auth#cors)
Quickstart includes the necessary forms and routing to quickly use Angular2-Token with your Project. A live demo can be found [here](https://angular2-token.herokuapp.com/#/session/sign-in).
48
+
49
+
Quickstart is currently in αlpha, please use with caution.
50
+
51
+

52
+
53
+
1. Add `A2tUiModule` to your main module.
54
+
```javascript
55
+
import { Angular2TokenService, A2tUiModule } from 'angular2-token';
56
+
57
+
@NgModule({
58
+
imports: [
59
+
BrowserModule,
60
+
HttpModule,
61
+
RouterModule,
62
+
A2tUiModule
63
+
],
64
+
declarations: [ AppComponent ],
65
+
providers: [ Angular2TokenService ],
66
+
bootstrap: [ AppComponent ]
67
+
})
83
68
```
84
69
70
+
The `A2tUiModule` adds the following routes to your project:
|`session/update-password`| Update password for email redirect |
78
+
79
+
On successful sign in the user will be redirect to `restricted`.
80
+
81
+
## Content
82
+
- [Configuration](#configuration)
83
+
- [Service Methods](#methods)
84
+
- [`.signIn()`](#signin)
85
+
- [`.signOut()`](#signout)
86
+
- [`.registerAccount()`](#registeraccount)
87
+
- [`.deleteAccount()`](#deleteaccount)
88
+
- [`.validateToken()`](#validatetoken)
89
+
- [`.updatePassword()`](#updatepassword)
90
+
- [`.resetPassword()`](#resetpassword)
91
+
- [HTTP Service Wrapper](#http-service-wrapper)
92
+
- [Multiple User Types](#multiple-user-types)
93
+
- [Route Guards](#route-guards)
94
+
- [Advanced Usage](#advanced-usage)
95
+
- [`.sendHttpRequest()`](#sendhttprequest)
96
+
- [`.userSignedIn()`](#usersignedin)
97
+
- [`.currentUserType`](#currentusertype)
98
+
- [`.currentUserData`](#currentuserdata)
99
+
- [`.currentAuthData`](#currentauthdata)
100
+
- [Common Problems](#commonproblems)
101
+
- [Development](#development)
102
+
- [Testing](#testing)
103
+
- [Credits](#credits)
104
+
- [License](#license)
105
+
85
106
## Configuration
86
107
Configuration options can be passed as `Angular2TokenOptions` via `.init()`.
87
108
@@ -368,6 +389,18 @@ this._tokenService.signIn({
368
389
error => console.log(error)
369
390
);
370
391
```
392
+
## Common Problems
393
+
394
+
### CORS Configuration
395
+
If you are using CORS in your Rails API make sure that `Access-Control-Expose-Headers` includes `access-token`, `expiry`, `token-type`, `uid`, and `client`.
396
+
For the rack-cors gem this can be done by adding the following to its config.
397
+
More information can be found [here](https://github.com/lynndylanhurley/devise_token_auth#cors).
0 commit comments