Removing a user in iOS using Parse login

I am using the parsing login in iOS using swift. From the login controller, I get new users for registration through swift, using only email and password. This creates a PFUser that saves correctly in the Parse backend. Then, the user goes to the UserDetails view controller to “fill out” their registration by providing more detailed information that will be stored in coredata (im using parsing functions for registration only). If the user cancels, before "completing" the additional data, I want to remove the PFUser from the parsing created perhaps earlier. The code in the UserDetails view manager in the cancelTapped ibaction im file is running

            if PFUser.currentUser() != nil {
            PFUser.currentUser()?.deleteInBackgroundWithBlock({ (deleteSuccessful, error) -> Void in
                print("success = \(deleteSuccessful)")
            })

            //user deleted in background block above but still logged in so now logout
            PFUser.logOut()
        }

but im receives the following parsing error [Error]: A user cannot be deleted unless it is authenticated. (Code: 206, Version: 1.8.5) .... I do not know what authentication process is needed, and I assume that the problem may be due to the fact that they managed to delete the user before parsing, which has time to create a user in the first place .... any help or suggestions are appreciated

+4
source share
1 answer

ALC - / . , , / . , , , . deleteInBackgroundWithBlock.

if PFUser.currentUser() != nil {
        PFUser.currentUser()?.deleteInBackgroundWithBlock({ (deleteSuccessful, error) -> Void in
            print("success = \(deleteSuccessful)")
            PFUser.logOut()
        })         
}
+4

Source: https://habr.com/ru/post/1617146/


All Articles