Skip to content

Commit c804664

Browse files
jamesdanielsdavideast
authored andcommitted
docs(auth): Flushed out the auth example a bit more
1 parent 8ab3803 commit c804664

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

docs/auth/getting-started.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,22 @@ import * as firebase from 'firebase/app';
1717
@Component({
1818
selector: 'app-root',
1919
template: `
20-
<div> {{ (user | async)?.uid }} </div>
21-
<button (click)="login()">Login</button>
22-
<button (click)="logout()">Logout</button>
20+
<div *ngIf="afAuth.authState | async; let user; else showLogin">
21+
<h1>Hello {{ user.displayName }}!</h1>
22+
<button (click)="logout()">Logout</button>
23+
</div>
24+
<ng-template #showLogin>
25+
<p>Please login.</p>
26+
<button (click)="login()">Login with Google</button>
27+
</ng-template>
2328
`,
2429
})
2530
export class AppComponent {
26-
27-
user: Observable<firebase.User>;
28-
2931
constructor(public afAuth: AngularFireAuth) {
30-
this.user = afAuth.authState;
3132
}
32-
3333
login() {
3434
this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
3535
}
36-
3736
logout() {
3837
this.afAuth.auth.signOut();
3938
}

0 commit comments

Comments
 (0)