Reputation:
I am trying to create a node in database in Firebase but nothing happens.
Auth.auth().createUser(withEmail: (emailTextField.text!), password: (passwordTextField.text!)) { (result, error) in
if let _eror = error {
print(_eror.localizedDescription )
} else {
var ref: DatabaseReference!
ref = Database.database().reference()
ref.child("users").child((result?.user.uid)!).setValue(["username": self.usernameTextField.text!])
}
}
When I click 'Sign Up', I find that it's still having a new user created in Firebase.
Upvotes: 0
Views: 147
Reputation: 7546
The console output you shared shows the error:
setValue: or removeValue: at /users/E7... failed permission_denied
Check the rules for your Firebase project database and ensure that write access is granted
{
"rules": {
"users":{
"$user_id": {
".write": "auth.uid == user_id"
}
}
}
}
Upvotes: 2