How to change email in firebase auth?

前端 未结 4 2018
-上瘾入骨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:09

    updateEmail needs to happen right after sign in due to email being a security sensitive info
    Example for Kotlin

     // need to sign user in immediately before updating the email 
            auth.signInWithEmailAndPassword("currentEmail","currentPassword")
            .addOnCompleteListener(this) { task ->
                    if (task.isSuccessful) {
                        // Sign in success now update email                
                        auth.currentUser!!.updateEmail(newEmail)
                            .addOnCompleteListener{ task ->
                            if (task.isSuccessful) {
                   // email update completed
               }else{
                   // email update failed
                        }
           }
           } else {
                        // sign in failed
                    }
                }
    

提交回复
热议问题