Skip to content

Commit

Permalink
Fixed incorrect await in constructor in readme sample
Browse files Browse the repository at this point in the history
OKTA-383070
<<<Jenkins Check-In of Tested SHA: faf3fcf for [email protected]>>>
Artifact: okta-angular
  • Loading branch information
denysoblohin-okta authored and eng-prod-CI-bot-okta committed Apr 5, 2021
1 parent bef8c5a commit 521b0a3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ The example below shows connecting two buttons to handle **login** and **logout*
```typescript
// sample.component.ts

import { Component, OnInit } from '@angular/core';
import { OktaAuthService } from '@okta/okta-angular';

@Component({
Expand All @@ -281,21 +282,22 @@ import { OktaAuthService } from '@okta/okta-angular';
export class MyComponent {
isAuthenticated: boolean;
constructor(public oktaAuth: OktaAuthService) {
// get authentication state for immediate use
await this.isAuthenticated = this.oktaAuth.isAuthenticated();

// subscribe to authentication state changes
this.oktaAuth.$authenticationState.subscribe(
(isAuthenticated: boolean) => this.isAuthenticated = isAuthenticated
);
}
login() {
this.oktaAuth.signInWithRedirect({
async ngOnInit() {
// get authentication state for immediate use
this.isAuthenticated = await this.oktaAuth.isAuthenticated();
}
async login() {
await this.oktaAuth.signInWithRedirect({
originalUri: '/profile'
});
}
logout() {
this.oktaAuth.signOut();
async logout() {
await this.oktaAuth.signOut();
}
}
```
Expand Down

0 comments on commit 521b0a3

Please sign in to comment.