Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ion-card *ngIf="userProfile">
- <img [src]="userProfile.photoURL"/>
- <ion-card-content>
- <ion-card-title>
- {{ userProfile.displayName }}
- </ion-card-title>
- <p>
- The UID for this new user is {{userProfile.uid}} and the email is
- {{userProfile.email}}
- </p>
- </ion-card-content>
- </ion-card>
- userProfile: any;
- constructor(public navCtrl: NavController, public navParams: NavParams, public _authProvider: AuthProvider) {
- }
- _fbLogin() {
- this._authProvider._fbLogin();
- }
- _signOut() {
- this._authProvider._signOut();
- }
- userProfile: any = null;
- constructor(public _afAuth: AngularFireAuth, public _fb: Facebook) {
- console.log('Hello AuthProvider Provider');
- }
- _fbLogin(){
- this._fb.login(['email']).then( (response) => {
- const facebookCredential = firebase.auth.FacebookAuthProvider
- .credential(response.authResponse.accessToken);
- firebase.auth().signInWithCredential(facebookCredential)
- .then((success) => {
- console.log("Firebase success: " + JSON.stringify(success));
- this.userProfile = success;
- })
- .catch((error) => {
- console.log("Firebase failure: " + JSON.stringify(error));
- });
- }).catch((error) => { console.log(error) });
- }
- _signOut(){
- this._afAuth.auth.signOut();
- }
- _afAuth.authState.subscribe((user: firebase.User) => {
- if (!user) {
- this.userProfile = null;
- return;
- }
- this.userProfile = user.displayName;
- });
Add Comment
Please, Sign In to add comment