title: iOS SWIFT: Unable to delete user from Firebase Database
body: <p>I want to delete my current user from Firebase. The authenticated user gets deleted however, I am unable to delete the data for that user in the database. What am i doing wrong?</p>
  
  <p>This is my delete user method....</p>
  
  <pre><code>FIRAuth.auth()?.signIn(withEmail: (emailTextField?.text)! , password: (passwordTextField?.text)!, completion: { (user, error) in
              if error == nil {
                  print("User Authenticate!!!")
                  let user = FIRAuth.auth()?.currentUser
  
                  user?.delete(completion: { (error) in
                      if error != nil {
                          print("Error unable to delete user")
  
                      } else {
  
                          DataService.ds.deleteCurrentFirebaseDBUser()
                          KeychainWrapper.standard.removeObject(forKey: KEY_UID)
                          self.performSegue(withIdentifier: "goToLogin", sender: nil)
                      }
                  })
  
              } else {
                  //Password was wrong, unable to authenicate user. Data is not updated
                  print("!!!ALERT!!! Unable to authenticate user")
                  let alert = UIAlertController(title: "Incorrect Password", message: "Please re-enter your password", preferredStyle: UIAlertControllerStyle.alert)
                  alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
                  self.present(alert, animated: true, completion: nil)
              }
  
          })
  </code></pre>
  
  <p>Firebase Rules:</p>
  
  <pre><code>{
  "rules": {
      "users": {
        "$uid": {
          ".read": "$uid === auth.uid",
          ".write": "$uid === auth.uid"
        }
      }
    }
  }
  </code></pre>
  
  <p>Database:</p>
  
  <pre><code>App
     -&gt; users
             -&gt;
               4erkjkl543jfe46
                              -&gt;name
                              -&gt;email
  </code></pre>
  
  <p>ERRORS:</p>
  
  <p>2017-01-21 21:33:10.321704 APP[11582:4102711] [FirebaseDatabase] setValue: or removeValue: at /users/4erkjkl543jfe46 failed: permission_denied</p>
  
  <p>Optional(Error Domain=com.firebase Code=1 "Permission denied" UserInfo={NSLocalizedDescription=Permission denied})</p>