Does deleting account from Firebase automatically logs user out?

℡╲_俬逩灬. 提交于 2019-12-05 18:37:57

If you are deleting your currentUser you need to take care of two things:-

  • Delete the user's data from the Firebase Database (If there is any)
  • Delete the auth Credentials (e.g :- email-password, facebook login, twitter etc)

    To delete your current user use the below function, which also first sign's out the user

     FIRAuth.auth()?.currentUser?.delete(completion: { (err) in
    
        print(err?.localizedDescription)
    
    })
    

    If you CMD+CLICK on the delete function it will take you to its documentation :-

Deletes the user account (also signs out the user, if this was the current user).

completion Optionally; the block invoked when the request to delete the account is complete, or fails. Invoked asynchronously on the main thread in the future.

Possible error codes: - @c FIRAuthErrorCodeRequiresRecentLogin - Updating email is a security sensitive operation that requires a recent login from the user. This error indicates the user has not signed in recently enough. To resolve, reauthenticate the user by invoking reauthenticateWithCredential:completion: on FIRUser.

See @c FIRAuthErrors for a list of error codes that are common to all FIRUser operations. */

So long story short if the err received is nil your current users's account has not only been deleted but also signed out automatically, But you will need to handle other FIRAuthErrors as stated in the documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!