File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -17,23 +17,22 @@ import * as firebase from 'firebase/app';
17
17
@Component ({
18
18
selector: ' app-root' ,
19
19
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>
23
28
` ,
24
29
})
25
30
export class AppComponent {
26
-
27
- user: Observable <firebase .User >;
28
-
29
31
constructor (public afAuth : AngularFireAuth ) {
30
- this .user = afAuth .authState ;
31
32
}
32
-
33
33
login() {
34
34
this .afAuth .auth .signInWithPopup (new firebase .auth .GoogleAuthProvider ());
35
35
}
36
-
37
36
logout() {
38
37
this .afAuth .auth .signOut ();
39
38
}
You can’t perform that action at this time.
0 commit comments