当前位置:  开发笔记 > IOS > 正文

iOS SWIFT:无法从Firebase数据库中删除用户

如何解决《iOSSWIFT:无法从Firebase数据库中删除用户》经验,为你挑选了0个好方法。

我想从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 =权限被拒绝})

推荐阅读
Gbom2402851125
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有