Skip to content

Commit be90af5

Browse files
committed
Added parameters for register and delete path
1 parent 41eaa32 commit be90af5

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,28 @@ Angular2-Token is currently in Alpha. Any contribution is much appreciated.
4343
})
4444
```
4545
46-
3. Inject `Angular2TokenService` into your component and call `.init()`
46+
3. Inject `Angular2TokenService` into your component and call `.init()`.
4747
```javascript
4848
constructor(private _tokenService: Angular2TokenService) {
4949
this._tokenService.init();
5050
}
5151
```
5252
5353
## Configuration
54-
Configuration options can be passed as `Angular2TokenOptions` via `.init()`
54+
Configuration options can be passed as `Angular2TokenOptions` via `.init()`.
5555
5656
### Default Configuration
5757
```javascript
5858
constructor(private _tokenService: Angular2TokenService) {
5959
this._tokenService.init({
60-
apiPath: '',
61-
signInPath: 'auth/sign_in',
62-
signOutPath: 'auth/sign_out',
63-
validateTokenPath: 'auth/validate_token',
64-
updatePasswordPath: 'auth/password',
65-
userTypes: null
60+
apiPath: null,
61+
signInPath: 'auth/sign_in',
62+
signOutPath: 'auth/sign_out',
63+
registerAccountPath: 'auth',
64+
deleteAccountPath: 'auth',
65+
validateTokenPath: 'auth/validate_token',
66+
updatePasswordPath: 'auth/password',
67+
userTypes: null
6668
});
6769
}
6870
```

src/angular2-token.model.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ export interface UserType {
33
path: string;
44
}
55

6+
export interface AuthData {
7+
accessToken: string;
8+
client: string;
9+
expiry: string;
10+
tokenType: string;
11+
uid: string;
12+
}
13+
614
export interface Angular2TokenOptions {
715
apiPath?: string;
816
signInPath?: string;
917
signOutPath?: string;
18+
registerAccountPath?: string,
19+
deleteAccountPath?: string,
1020
validateTokenPath?: string;
1121
updatePasswordPath?: string;
1222
userTypes?: UserType[];
1323
}
14-
15-
export interface AuthData {
16-
accessToken: string;
17-
client: string;
18-
expiry: string;
19-
tokenType: string;
20-
uid: string;
21-
}

src/angular2-token.service.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ export class Angular2TokenService {
3030
init(options?: Angular2TokenOptions) {
3131

3232
let defaultOptions: Angular2TokenOptions = {
33-
apiPath: null,
34-
signInPath: 'auth/sign_in',
35-
signOutPath: 'auth/sign_out',
36-
validateTokenPath: 'auth/validate_token',
37-
updatePasswordPath: 'auth/password',
38-
userTypes: null
33+
apiPath: null,
34+
signInPath: 'auth/sign_in',
35+
signOutPath: 'auth/sign_out',
36+
registerAccountPath: 'auth',
37+
deleteAccountPath: 'auth',
38+
validateTokenPath: 'auth/validate_token',
39+
updatePasswordPath: 'auth/password',
40+
userTypes: null
3941
};
4042

4143
this._options = Object.assign(defaultOptions, options);
@@ -57,12 +59,12 @@ export class Angular2TokenService {
5759
password_confirmation: passwordConfirmation
5860
});
5961

60-
return this.post(this._constructUserPath(), body).map(res => res.json());
62+
return this.post(this._constructUserPath() + this._options.registerAccountPath, body).map(res => res.json());
6163
}
6264

6365
// Delete Account
6466
deleteAccount(): Observable<Response> {
65-
return this.delete(this._constructUserPath()).map(res => res.json());
67+
return this.delete(this._constructUserPath() + this._options.registerAccountPath).map(res => res.json());
6668
}
6769

6870
// Sign in request and set storage

0 commit comments

Comments
 (0)