Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

279
Vistas
How to update email and sensitive data properly in Firebase?

I have a code where the user can update his credentials/personal information however I encounter a problem and managed to fix it, it was saying first argument had to be an string and I found a solution however I got an error afterwards saying "This operation is sensitive and requires recent authentication. Log in again before retrying...

enter image description here

Afterwards I found in some of the comments where I found my first solution the following: user.reauthenticateWithCredential(auth.EmailAuthProvider.credential(user.email, user.password)).then(() => user.updateEmail(email)) I tried to use this but is not working I get other error afterwards and wanted to know if this was either outdated or I'm just doing this wrong.

enter image description here

Code

I get my auth from my firebase.js

const db = firebase.firestore();
const auth = firebase.auth();
const storage = firebase.storage();

I get my user from my App.js and then if I need it I just send it just like this:

function App() {

const [user, setUser] = useState([]);

  useEffect(() => {
    auth.onAuthStateChanged((authUser) => {

      if (authUser) {
        setUser(authUser);
      } else {
        setUser(false);
      }
    })
  }, [])

return (
....
<Route path = "/Update_Profile">
            <Inicio user={user}/>
            <UpdateProfile user={user}/>
          </Route>
...
)}

export default App;

const updateEmail = (e) => {
        e.preventDefault();
        
        if (user && (email != "")) {
            user.reauthenticateWithCredential(auth.EmailAuthProvider.credential(user.email, user.password))
            .then(() => user.updateEmail(email))
            
            const ref = db.collection("usuarios").doc(user.uid)
            ref.update({
                email: email
            })
        } else {
            //User is not logged in, handle that case here
        }
    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because auth is an instance of the Auth module and not the namespace of the Auth module from the Firebase Web SDK (because you've used const auth = firebase.auth()), the following value is undefined:

auth.EmailAuthProvider

This is because the firebase.auth.Auth class does not define a property EmailAuthProvider. This then means JavaScript tries to call undefined.credential(...) and throws an error.

To access the EmailAuthProvider class, you need to access it from the firebase.auth namespace directly:

firebase.auth.EmailAuthProvider

In short,

firebase.auth !== firebase.auth()
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda