0

我有我没有找到太多的信息有问题,我甚至看this但我无法找到此异常的解决方案:火力地堡/阵营原住民 - 断言失败

断言失败:opt_onRejected应该是一个功能。你是否将opt_context作为第二个参数而不是第三个参数?

这里是我的功能会抛出异常:

const {currentUser} = firebase.auth() 
    const credential = firebase.auth.EmailAuthProvider.credential(
    currentUser.email, 
    password) 

    return (dispatch) => { 
    currentUser.reauthenticate(credential) // 1. Re-authenticate 
    .then(
    console.log("RE-AUTH"), 
    currentUser.updateEmail(strEmail) // 2. Update email 
    .then(
     console.log("MAIL UPDATE"), 
     firebase.database().ref(`users/${currentUser.uid}/`) // 3. Update profile email 
     .update({email}) 
     .then(console.log("PROFILE UPDATE")) 
     .catch(error => console.log(error)) 
    ) 
     .catch(error => console.log(error)) 
    ) 
    .catch(error => console.log(error)) 
    } 

它的工作原理,因为它改变了电子邮件地址,但除了显示...

回答

0

固定的问题,我增加了更多的console.log()到发现我的承诺 答案处理不正确(link)。

如果有人需要电子邮件更改一个工作动作:

currentUser.reauthenticate(credential) // Re-authenticate 
.then(() => { 
    currentUser.updateEmail(strEmail) // Update email 
    .then(() => { 
    firebase.database().ref(`users/${currentUser.uid}/`) // Update profile email 
    .update({email}) 
    .then(() => 
     Alert.alert("Modification saved."), 
     emailSaveSuccess(dispatch) 
    ) 
    .catch(error => console.log(error)) 
    }) 
    .catch(error => emailSaveError(dispatch, error)) 
}) 
.catch(error => emailSaveError(dispatch, error))