小编Dan*_*sen的帖子

如何在 firebase 身份验证中为 .reauthenticateWithCredential() 创建凭据参数?

要在 firebase auth 中删除/编辑用户信息,您需要最近登录过。这可以使用 .reauthenticateWithCredential() 来完成。我怎样才能在javascript中为此创建凭证(使用电子邮件身份验证)?我尝试过(电子邮件,密码)和({电子邮件,密码}),但没有运气。

代码:

function reauth() {
        const credential = firebase.auth.EmailAuthProvider.credential(user.auth.email, password);

        user.reauthenticateWithCredential(credential).then(function() {
                firebase.firestore().collection('users').doc(uid).delete().then(() => {
                    user.delete().then(function() {
                        navigation.replace("Signup")
                    }).catch(function(error) {
                        console.log(error)
                    })
                }).catch((error) => {
                    console.log(error)
                })
        }).catch(function(error) {
            console.log(error)
        })
    }
Run Code Online (Sandbox Code Playgroud)

javascript authentication firebase firebase-authentication

2
推荐指数
1
解决办法
1523
查看次数