我能够在Firebase身份验证中对用户进行身份验证,但不能像在Firebase数据库中的名字和姓氏一样存储他们的数据。我编写的代码可能有问题吗?
Auth.auth().createUser(withEmail: userEmail, password: userPassword) { (user, error) in
if let error = error
{
print(error.localizedDescription)
self.showMessage(messageToDisplay: error.localizedDescription)
return
}
if let user = user {
var databaseReference: DatabaseReference!
databaseReference = Database.database().reference()
let userDetails:[String:String] = ["firstName":firstName, "lastName":lastName]
databaseReference.child("users").child(user.uid).setValue(["userDetails":userDetails])
答案 0 :(得分:0)
尝试为此设置实时数据库规则:
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}