我想从Firebase中删除当前用户。然而,经过身份验证的用户被删除,我无法删除数据库中该用户的数据。我究竟做错了什么?iOS SWIFT:无法从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)
}
})
火力地堡规则:
{
"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] [Fir ebaseDatabase]的setValue:或removeValue:在/用户/ 4erkjkl543jfe46失败:PERMISSION_DENIED
可选(错误域= com.firebase代码= 1 “权限被拒绝” 的UserInfo = {NSLocalizedDescription =权限被拒绝})
有道理。真棒!谢谢,这使它工作。 – Nick