这是我使用 swift 和 firebase 的 iOS 应用程序的编辑按钮。
var ref = Firebase(url:"https://·············.firebaseio.com")
@IBAction func Done(sender: AnyObject) {
ref.changeEmailForUser("users/\(self.ref.authData.uid)/email",
password: "users/\(self.ref.authData.uid)/provider", toNewEmail: EmailTextField.text)
{ (ErrorType) -> Void in
if ErrorType != nil {
print("There was an error processing the request")
} else {
print("Email changed successfully")
}
}
ref.changePasswordForUser("users/\(self.ref.authData.uid)/email",
fromOld: "users/\(self.ref.authData.uid)/provider", toNew: PasswordTextField.text)
{ (ErrorType) -> Void in
if ErrorType != nil {
print("There was an error processing the request")
} else {
print("Password changed successfully")
}
}
ref.childByAppendingPath("users").childByAppendingPath(self.ref.authData.uid).updateChildValues(["name":self.NameTextField.text!,"about":self.TextView.text!,"Picker":self.PickerVar])
}
当用户点击完成按钮时,我想更新他在 firebase 中的所有信息。 电子邮件、密码、姓名等
当我点击完成按钮时,所有信息都更新了,除了电子邮件和密码! 据说处理请求时出错: as the picture here
不知道哪里出错了!我是否以错误的方式使用了 changeEmailForUser 和 changePasswordForUser 函数?
这是 JSON 树:
{
"users" : {
"7b595e99-b20d-4961-bcf0-6c46956a0cbe" : {
"Picker" : "Student",
"about" : "Hey, I'm Here",
"email" : "mariah@gmail.com",
"name" : "Mariah Khayat",
"provider" : "password"
},
"7eb23db6-6b56-4225-9306-22ed0b935b52" : {
"Picker" : "Teacher",
"about" : "Hi",
"email" : "mmm@gmail.com",
"name" : "Memo",
"provider" : "password"
}
}
}
最佳答案
根据 Firebase API 造成一些混淆。在我看到 API 之后 https://www.firebase.com/docs/ios/api/#firebase_changeEmailForUserpasswordtoNewEmailwithCompletionBlock有明确的说:
因此对于用户的更新电子邮件,这不是更新配置文件的一部分。因此,您可以按照以下方式更改您的电子邮件地址:
ref.changeEmailForUser("OldEmailthatYouuserForLogin", password: "correctpassword",
toNewEmail: "newEmail", withCompletionBlock: { error in
if error != nil {
print("There was an error processing the request")
// There was an error processing the request
} else {
print("Email changed successfully")
// Email changed successfully
}
})
// Dont use edited email for the old email and edited password for the password make sure you are using your actually email and password
关于ios - 使用 Swift 和 Firebase 更改用户电子邮件和密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35953867/