Skip to content

Instantly share code, notes, and snippets.

@Saad-Amjad
Last active November 5, 2018 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saad-Amjad/bfda1a3a0e3473faf8e3b4ebc8a607b3 to your computer and use it in GitHub Desktop.
Save Saad-Amjad/bfda1a3a0e3473faf8e3b4ebc8a607b3 to your computer and use it in GitHub Desktop.
Firebase Auth Snippet
export class LoginComponent {
constructor(public afAuth: AngularFireAuth) {}
fbLogin() {
this.afAuth.auth.signInWithPopup(new auth.FacebookAuthProvider()).then(
res => {},
err => {
console.log(err);
}
);
}
googleLogin() {
this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider()).then(
res => {},
err => {
console.log(err);
}
);
}
authState () {
this.afAuth.authState.subscribe(auth => {
if (auth) {
this.userId = auth.uid;
}
});
}
logout() {
this.afAuth.auth.signOut();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment