Skip to content

Commit 4185e47

Browse files
committed
Update doc for ngx branch.
1 parent 338877a commit 4185e47

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,24 @@ $ npm install @ebondu/angular2-keycloak --save
1515
To generate all `*.js`, `*.js.map` and `*.d.ts` files:
1616

1717
```bash
18-
$ npm run build
19-
```
20-
21-
To lint all `*.ts` files:
22-
23-
```bash
24-
$ npm run lint
18+
$ npm run build:dist
2519
```
2620

2721
## Usage
2822

2923
Declare Keycloak module in angular app :
3024

3125
```javascript
32-
import { Ng2KeycloakModule } from '@ebondu/angular2-keycloak';
26+
import { KeycloakModule } from '@ebondu/angular2-keycloak';
3327
...
3428

3529
@NgModule({
3630
declarations: [
3731
AppComponent
3832
],
3933
imports: [
40-
Ng2KeycloakModule.forRoot()
34+
HttpModule,
35+
KeycloakModule.forRoot()
4136
],
4237
providers: [
4338
...
@@ -64,15 +59,15 @@ export class MyLoginClass implements OnInit {
6459
constructor( private keycloak: Keycloak, private keycloakAuthz: KeycloakAuthorization) {
6560
Keycloak.authenticatedObs.subscribe(auth => {
6661
this.isAuthenticated = auth;
67-
this.parsedToken = Keycloak.tokenParsed;
62+
this.parsedToken = this.keycloak.tokenParsed;
6863

6964
console.info('APP: authentication status changed...');
7065
});
7166
}
7267

7368
ngOnInit() {
7469
// Configure the Keycloak
75-
Keycloak.config = 'assets/keycloak.json';
70+
this.keycloak.config = 'assets/keycloak.json';
7671

7772
// Initialise the Keycloak
7873
this.keycloakAuthz.init();
@@ -83,15 +78,17 @@ export class MyLoginClass implements OnInit {
8378
}
8479

8580
login() {
81+
// you should pass your login options
8682
Keycloak.login({});
8783
}
8884

8985
logout() {
86+
// you should pass your logout options
9087
Keycloak.logout({});
9188
}
9289

9390
loadProfile() {
94-
Keycloak.loadUserProfile().subscribe(profile => {
91+
this.keycloak.loadUserProfile().subscribe(profile => {
9592
this.profile = profile;
9693
});
9794
}
@@ -110,7 +107,7 @@ import { Http } from '@angular/http';
110107

111108
@Injectable()
112109
export class MyClass {
113-
// Angualar will inject the instance of the KeycloakHttp class
110+
// Angular will inject the instance of the KeycloakHttp class
114111
constructor(private http: Http) {}
115112

116113
callAPI(): Observable<MyObject> {

0 commit comments

Comments
 (0)