我想从Firebase中删除当前用户.已验证的用户被删除但是,我无法删除数据库中该用户的数据.我究竟做错了什么?
这是我的删除用户方法....
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) } })
Firebase规则:
{ "rules": { "users": { "$uid": { ".read": "$uid === auth.uid", ".write": "$uid === auth.uid" } } } }
数据库:
App -> users -> 4erkjkl543jfe46 ->name ->email
错误:
2017-01-21 21:33:10.321704 APP [11582:4102711] [FirebaseDatabase] setValue:或removeValue:at/users/4erkjkl543jfe46 failed:permission_denied
可选(错误域= com.firebase代码= 1"权限被拒绝"UserInfo = {NSLocalizedDescription =权限被拒绝})