How to change email in firebase auth?

前端 未结 4 2041
-上瘾入骨i
-上瘾入骨i 2020-12-29 20:08

I am trying to change/update a user\'s email address using :

firebase.auth().changeEmail({oldEmail, newEmail, password}, cb)

But I am getti

4条回答
  •  悲哀的现实
    2020-12-29 21:01

    You're looking for the updateEmail() method on the firebase.User object: https://firebase.google.com/docs/reference/js/firebase.User#updateEmail

    Since this is on the user object, your user will already have to be signed in. Hence it only requires the password.

    Simple usage:

    firebase.auth()
        .signInWithEmailAndPassword('you@domain.com', 'correcthorsebatterystaple')
        .then(function(userCredential) {
            userCredential.user.updateEmail('newyou@domain.com')
        })
    

提交回复
热议问题