Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Firebase Login getting User's info

$
0
0

@iconio wrote:

Hey guys, I’ve been having a hard time with Firebase and I wonder if anybody could help me out.

I’m at the ‘main page’ of my application, the user has already been logged in using the email and password authentication. After the user gets authenticated, he goes to a profile page, on which will grab the UID and ask for the First Name, Last Name and Nickname. No problem with that part.

Now, I need to be able to pull that information from the user and display on the screen, something like “Hey FirstName, how are you”.

I’ve been testing out and I’m getting on the console a [object Object]. Can anybody shine a light into this for me?

Here is my code:

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AngularFireAuth } from 'angularfire2/auth';
import { User } from '../../models/user';
import { AngularFireObject } from 'angularfire2/database/interfaces';
import { Profile } from '../../models/profile';
import { AngularFireDatabase } from 'angularfire2/database';


@IonicPage()
@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
})
export class HomePage {
  profileData: AngularFireObject<Profile>;

  user = {} as User;
  profile = {} as Profile;

  constructor(public navCtrl: NavController, public navParams: NavParams, private afAuth: AngularFireAuth, private afData: AngularFireDatabase) {
  }

  getCurrentUser() {
    this.afAuth.authState.subscribe(data => {
      console.log('A informacao de data ' + data.uid);
      return data.uid;
    });
  }

  getUserFirstName() {
    this.profileData = this.afData.object(`profile/` + this.getCurrentUser());
    return this.profileData;
  }

  ionViewDidLoad() {
    this.getUserFirstName();
    console.log('The Users first name is ' + this.getUserFirstName());
  }

}

I really really appreciate if anybody can help me out.

Cheers,

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>