无法重新验证用户以更改电子邮件或重置密码(Firebase..Swift)

时间:2019-07-17 04:25:03

标签: swift firebase firebase-authentication credentials

我无法对答案发表评论,对不起,我不得不问这个问题。

尝试重新验证用户身份时,我在Xcode上收到错误,因此他们的电子邮件和/或密码已更改。

这是我编写的代码。


    var credential: AuthCredential

    let user = Auth.auth().currentUser
            // re authenticate the user
        user?.reauthenticate(with: credential) { error in
            if let error = error {
                // An error happened.
            } else {
                // User re-authenticated.
            }
        }


        }

我收到一条错误消息,指出无法将类型'(_)->()'的值转换为预期的参数类型'AuthDataResultCallback? (又名“可选<(可选,可选)->()>”)

1 个答案:

答案 0 :(得分:1)

看起来reauthenticate函数返回一个元组,所以您必须更改代码:

var credential: AuthCredential

let user = Auth.auth().currentUser

// re authenticate the user
user?.reauthenticate(with: credential) { (authDataResult, error) in
    if let error = error {
        // An error happened.
    } else {
        // Use `user` property of result to check is successful.
    }
}

AuthDataResultCallback

FIRAuthDataResult