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

297
Views
UpdateProfile() durante el registro de Firebase

Estoy trabajando en una aplicación y quiero lograr esto. Cuando un usuario inicia sesión, quiero obtener su nombre de usuario y almacenarlo en firebase. Así que creé esto:

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

Y esto funciona, ahora necesito guardar también displayName en el usuario actual, así que trato de hacer esto dentro de la misma función (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"); });

Pero me da esto:

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

¿Cómo hacerlo? Estoy corriendo en ionic 2 angular2, firebase/angulrfire

Referencia del documento:

Actualizar el perfil de un usuario

Puede actualizar la información de perfil básica de un usuario (el nombre para mostrar del usuario y la URL de la foto de perfil) con el método updateProfile. Por ejemplo:

var usuario = firebase.auth().currentUser;

user.updateProfile({ displayName: "Jane Q. User", photoURL: " https://example.com/jane-q-user/profile.jpg " }).then(function() {
// Actualización exitosa. }, function(error) { // Ocurrió un error. });

Aquí

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Mi respuesta es demasiado tarde, pero en caso de que alguien esté interesado, podría hacerlo así.

 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 }); }

Puedes aprender más aquí

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!