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/5-user-authentication.md at master · raprav/angularfire2

Expand file tree

/

5-user-authentication.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
45 lines (34 loc) · 1.23 KB
/

5-user-authentication.md

Copy path

File metadata and controls

45 lines (34 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

5. User 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 availabile.

Example app:

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

@Component({
  selector: 'app-root',
  template: `
  <div> {{ (user | async)?.uid }} </div>
  <button (click)="login()">Login</button>
  <button (click)="logout()">Logout</button>
  `,
})
export class AppComponent {

  user: Observable<firebase.User>;

  constructor(public afAuth: AngularFireAuth) {
    this.user = afAuth.authState;
  }

  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.