且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Firebase中删除帐户是否会自动注销用户?

更新时间:2023-12-05 11:32:40

如果要删除 currentUser ,则需要注意以下两点:-

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

  • Firebase数据库中删除用户的数据(如果有的话)
  • 删除身份验证凭据(例如:-电子邮件密码,facebook登录名,twitter等)

  • 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)

})

如果您对删除功能进行CMD + CLICK,将带您进入其文档:-

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.

可能的错误代码: -@c FIRAuthErrorCodeRequiresRecentLogin-更新电子邮件是一项安全敏感的操作,需要用户最近登录.此错误表示用户最近没有登录过.要解决此问题,请通过在FIRUser上调用reauthenticateWithCredential:completion:来重新认证用户.

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.

有关所有FIRUser操作共有的错误代码列表,请参见@c FIRAuthErrors. */

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

长话短说,如果收到的 err 为零,那么您当前的帐户不仅会被删除,还会自动注销,但是您需要处理其他 FIRAuthErrors

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