Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
UpdateProfile() during singup Firebase

I'm working on an app and I want to achieve this. When an user signing in I want to get his username and store in firebase. So I created this :

Signup(email: string, password: string, displayName: string) {
    this.angFire.auth.createUser({
      email: email,
      password: password
    }).catch(
      (err) => {
        console.log(err);
        this.error = err;
      })
...

And this works, now I need to save also displayName into current user, so I try to do this inside the same function (Singup()) :

let user = firebase.auth().currentUser;
    user.updateProfile({
      displayName: this.displayName,
      photoURL: "https://example.com/jane-q-user/profile.jpg"
    }).then(function() {
      console.log("Nome utente inserito");
    }, function(error) {
      console.log("Errore durante inserimento utente");
    });

But it gives me this :

error_handler.js:54 EXCEPTION: Error in ./SignupPage class SignupPage - inline template:70:4 caused by: Cannot read property 'updateProfile' of null

How to do it? I'm running on ionic 2 angular2, firebase/angulrfire

Doc ref :

Update a user's profile

You can update a user's basic profile information—the user's display name and profile photo URL—with the updateProfile method. For example:

var user = firebase.auth().currentUser;

user.updateProfile({ displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg" }).then(function() {
// Update successful. }, function(error) { // An error happened. });

Here

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

My answer is way too late but just in case someone is interested, you could do it like this

  constructor(
    private afAuth: AngularFireAuth,
    private router: Router
  ) { 
   //
  }


async signupUser(email: string, password: string): Promise<any> {
    const data = await this.afAuth.createUserWithEmailAndPassword(
      email,
      password
    );
    return this.updateUserData(data.user).then(() => {
      this.router.navigate(["/"]);
    });
  }

 private updateUserData({ uid, email, photoURL, displayName }: User) {
    const userRef: AngularFirestoreDocument<User> = this.afs.doc(
      `users/${uid}`
    );
    return userRef.set({ uid, email, photoURL, displayName }, { merge: true });
 }

You can learn more here

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!