Skip to content

Commit 71fb89d

Browse files
committed
Added quickstart to readme
1 parent b58e81e commit 71fb89d

File tree

5 files changed

+105
-72
lines changed

5 files changed

+105
-72
lines changed

README.md

Lines changed: 72 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,21 @@
77
[![Build Status](https://travis-ci.org/neroniaky/angular2-token.svg?branch=master)](https://travis-ci.org/neroniaky/angular2-token)
88
[![Angular 2 Style Guide](https://mgechev.github.io/angular2-style-guide/images/badge.svg)](https://angular.io/styleguide)
99

10-
## About
11-
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.
1411
Angular2-Token is currently in Alpha. Any contribution is much appreciated.
1512

16-
## Live Demo
1713
You can try out Angular2-Token [here](https://angular2-token.herokuapp.com/).
1814

1915
The repository can be found [here](https://github.com/neroniaky/angular2-token-example).
2016

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-
4617
## Installation
4718
1. Install Angular2-Token via NPM with
4819
```bash
4920
npm install angular2-token
5021
```
5122

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.
5324
```javascript
54-
import { HttpModule } from '@angular/http';
55-
import { RouterModule } from '@angular/router';
56-
5725
import { Angular2TokenService } from 'angular2-token';
5826
5927
@NgModule({
@@ -75,13 +43,66 @@ The repository can be found [here](https://github.com/neroniaky/angular2-token-e
7543
}
7644
```
7745
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)
81-
```ruby
82-
:expose => ['access-token', 'expiry', 'token-type', 'uid', 'client']
46+
## Quickstart (αlpha)
47+
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+
![Quickstart](assets/quickstart.gif)
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+
})
8368
```
8469
70+
The `A2tUiModule` adds the following routes to your project:
71+
72+
| Route | Description |
73+
| -------------------------- | ---------------------------------------- |
74+
| `session/sign-in` | Sign in form |
75+
| `session/sign-up` | Sign out form |
76+
| `session/reset-password` | Reset password form |
77+
| `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+
85106
## Configuration
86107
Configuration options can be passed as `Angular2TokenOptions` via `.init()`.
87108
@@ -368,6 +389,18 @@ this._tokenService.signIn({
368389
error => console.log(error)
369390
);
370391
```
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).
398+
```ruby
399+
:expose => ['access-token', 'expiry', 'token-type', 'uid', 'client']
400+
```
401+
402+
### Missing Routes
403+
Make sure that your projects includes some kind of routing.
371404
372405
## Development
373406
If the package is installed from Github specified in the package.json, you need to build the package locally.

angular2-token.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from './src/angular2-token.model';
22
export * from './src/angular2-token.service';
3-
export * from './src/a2t-ui/a2t-ui.module';
3+
export * from './src/a2t-ui/a2t-ui.module';

assets/quickstart.gif

421 KB
Loading

src/a2t-ui/a2t-ui.forms.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const SIGN_IN_FORM: BaseField[] = [
3434
}),
3535
new BaseField({
3636
key: 'password',
37-
label: 'Passwort',
37+
label: 'Password',
3838
type: 'password',
3939
validators: [
4040
Validators.required,
@@ -55,7 +55,7 @@ export const SIGN_UP_FORM: BaseField[] = [
5555
}),
5656
new BaseField({
5757
key: 'password',
58-
label: 'Passwort',
58+
label: 'Password',
5959
type: 'password',
6060
validators: [
6161
Validators.required,
@@ -64,7 +64,7 @@ export const SIGN_UP_FORM: BaseField[] = [
6464
}),
6565
new BaseField({
6666
key: 'passwordConfirmation',
67-
label: 'Passwort Confirmation',
67+
label: 'Password Confirmation',
6868
type: 'password',
6969
validators: [
7070
Validators.required,
@@ -88,7 +88,7 @@ export const RESET_PASSWORD_FORM: BaseField[] = [
8888
export const UPDATE_PASSWORD_FORM: BaseField[] = [
8989
new BaseField({
9090
key: 'password',
91-
label: 'Passwort',
91+
label: 'Password',
9292
type: 'password',
9393
validators: [
9494
Validators.required,
@@ -97,7 +97,7 @@ export const UPDATE_PASSWORD_FORM: BaseField[] = [
9797
}),
9898
new BaseField({
9999
key: 'passwordConfirmation',
100-
label: 'Passwort Confirmation',
100+
label: 'Password Confirmation',
101101
type: 'password',
102102
validators: [
103103
Validators.required,

tsconfig.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
{
2-
"compilerOptions": {
3-
"noImplicitAny": true,
4-
"module": "commonjs",
5-
"target": "ES5",
6-
"emitDecoratorMetadata": true,
7-
"experimentalDecorators": true,
8-
"sourceMap": true,
9-
//"declaration": true,
10-
"outDir": "lib",
11-
"suppressImplicitAnyIndexErrors": true
12-
},
13-
"files": [
14-
"src/angular2-token.service.ts",
15-
"src/a2t-ui/a2t-ui.module.ts"
16-
],
17-
"exclude": [
18-
"node_modules"
19-
],
20-
"types": [
21-
"core-js",
22-
"hammerjs",
23-
"jasmine",
24-
"node",
25-
"protractor",
26-
"source-map",
27-
"webpack"
28-
]
2+
"compilerOptions": {
3+
"noImplicitAny": true,
4+
"module": "commonjs",
5+
"target": "ES5",
6+
"emitDecoratorMetadata": true,
7+
"experimentalDecorators": true,
8+
"sourceMap": true,
9+
//"declaration": true,
10+
"outDir": "lib",
11+
"suppressImplicitAnyIndexErrors": true
12+
},
13+
"files": [
14+
"src/angular2-token.service.ts",
15+
"src/a2t-ui/a2t-ui.module.ts"
16+
],
17+
"exclude": [
18+
"node_modules"
19+
],
20+
"types": [
21+
"core-js",
22+
"hammerjs",
23+
"jasmine",
24+
"node",
25+
"protractor",
26+
"source-map",
27+
"webpack"
28+
]
2929
}

0 commit comments

Comments
 (0)