GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — angularfire2/docs/auth/getting-started.md at master · interrobrian/angularfire2

This repository was archived by the owner on Oct 16, 2023. It is now read-only.

Expand file tree

/

getting-started.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
43 lines (36 loc) · 1.31 KB
/

getting-started.md

Copy path

File metadata and controls

43 lines (36 loc) · 1.31 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

5. Getting started with Firebase Authentication

AngularFireAuth.authState provides you an Observable<firebase.User> to monitor your application's authentication State.

AngularFireAuth.auth returns an initialized firebase.auth.Auth instance, allowing you to log users in, out, etc. See the Firebase docs for more information on what methods are available.

Example app:

import { Component } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';

@Component({
  selector: 'app-root',
  template: `
    <div *ngIf="afAuth.authState | async as user; else showLogin">
      <h1>Hello {{ user.displayName }}!</h1>
      <button (click)="logout()">Logout</button>
    </div>
    <ng-template #showLogin>
      <p>Please login.</p>
      <button (click)="login()">Login with Google</button>
    </ng-template>
  `,
})
export class AppComponent {
  constructor(public afAuth: AngularFireAuth) {
  }
  login() {
    this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
  }
  logout() {
    this.afAuth.auth.signOut();
  }
}

Cordova

Learn how to setup Firebase Authentication with Cordova in the Firebase Guides.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.