我正在使用谷歌的新firebase开发应用程序.我在更新用户电子邮件和密码时遇到问题.
这是我尝试过的.
let currentUser = FIRAuth.auth()?.currentUser
currentUser?.updateEmail(email) { error in
if let error = error {
print(error)
} else {
// Email updated.
currentUser?.updatePassword(password) { error in
if let error = error {
} else {
// Password updated.
print("success")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是当更新密码时,会发生这样的错误.
"Domain = FIRAuthErrorDomain Code = 17014"此操作非常敏感,需要最近的身份验证..."
据我所知,我们必须在更新电子邮件后重新配置用户.
我尝试使用此代码从firebase重新配置.
let user = FIRAuth.auth()?.currentUser
var credential: FIRAuthCredential
// Prompt the user to re-provide their sign-in credentials
user?.reauthenticateWithCredential(credential) { error in
if let error = error {
// …Run Code Online (Sandbox Code Playgroud)