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

234
Views
Firebase v9 auth.currentUser es nulo después de crear el usuario

Aquí está mi código JS:

 import { ref } from "vue" import { projectAuth } from '../firebase/config' import { getAuth, createUserWithEmailAndPassword, updateProfile } from 'firebase/auth' const error = ref(null) const isPending = ref(false) const signup = async(email, password, displayName) => { error.value = null isPending.value = true try { const res = createUserWithEmailAndPassword(projectAuth, email, password) console.log(projectAuth.currentUser) if (!res) { console.log('Could not complete the signup') throw new Error('Could not complete the signup') } console.log(projectAuth.currentUser) await updateProfile(projectAuth.currentUser, {displayName}) error.value = null isPending.value = false return res } catch(err) { console.log('ERROR: ' + err.message) error.value = err.message isPending.value = false } } const useSignup = () => { return {error, signup, isPending} } export default useSignup

Mi aplicación Vue3 está llamando a la función de registro en este script cada vez que un usuario se registra. La función createUserWithEmailAndPassword es exitosa y el usuario aparece en firebase. Pero también quiero agregar un nombre para mostrar a mi usuario, así que estoy tratando de usar la función updateProfile para hacerlo, pero hay un problema.

El problema es que projectAuth.currentUser es nulo incluso después de crear el usuario y no puedo entender por qué.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El método createUserWithEmailAndPassword() devuelve una promesa. Dado que su función es async , intente agregar await :

 const res = await createUserWithEmailAndPassword(projectAuth, email, password) console.log(projectAuth.currentUser)

Alternativamente, puede pasar el objeto User a updateProfile directamente desde res:

 const { user } = await createUserWithEmailAndPassword(projectAuth, email, password) await updateProfile(user, { displayName })
about 4 years ago · Juan Pablo Isaza 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!