如何在firebase auth中更改电子邮件? [英] How to change email in firebase auth?

查看:21
本文介绍了如何在firebase auth中更改电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方法更改/更新用户的电子邮件地址:

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

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

但我收到 ...changeEmail is not a function 错误.我从旧的 firebase 文档中找到了参考这里.

But I am getting ...changeEmail is not a function error. I found the reference here from the old firebase docu.

那么我在 3.x 版本中怎么做呢?因为我在新文档中找不到参考.

So how to I do it in the 3.x version? Because I cant find a reference in the new documentation.

推荐答案

您正在寻找 firebase.User 对象上的 updateEmail() 方法:https://firebase.google.com/docs/reference/js/firebase.User#updateEmail

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.

简单用法:

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

这篇关于如何在firebase auth中更改电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆