Last active
November 5, 2018 07:38
-
-
Save Saad-Amjad/bfda1a3a0e3473faf8e3b4ebc8a607b3 to your computer and use it in GitHub Desktop.
Firebase Auth Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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