TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
223 stars 49 forks source link

[Feature] Provide Reauthenticate method under CrossFirebaseAuth.Current.CurrentUser #52

Closed Kapusch closed 6 months ago

Kapusch commented 2 years ago

Hi @TobiasBuchholz , recently Apple requested app developers to provide a way for their users to delete their account.

I was happy to find the DeleteAsync method under CrossFirebaseAuth.Current.CurrentUser, however I have faced a FIRAuthErrorCodeRequiresRecentLogin which basically indicates the user has attempted a sensitive operation more than 5 minutes after signing in, and then requires recent authentication.

I could prompt a dialog for the user to be able to reauthenticate, however this is not suitable for users who signed in with Google, Facebook or Apple.

I can explain to my users that they need to reauthenticate and quickly go for the deletion of their account, however this would be neat having a Reauthenticate method under CrossFirebaseAuth.Current.CurrentUser.

I can see from the docs there is a way to do so with providers as well.

angelru commented 1 year ago

@Kapusch I am facing the same issue, how did you solve it?

Kapusch commented 1 year ago

Hey @angelru , I did not solve it actually. All I was able to do is catching error code for FIRAuthErrorCodeRequiresRecentLogin: catch (Exception ex) when (ex.Message.Contains("17014"))

so that I can inform the user must re-authenticate for security reasons before they can delete their account.

Note: this DeleteAsync() method only remove the user from the Firebase instance, you still have to delete all the Firestore / Storage data manually.

AdamEssenmacher commented 1 year ago

This plugin is built on the Xamarin.iOS bindings published by Microsoft. The reauthenticate method in these bindings has been broken since version 6, and this PR to fix it is almost a year old.

So, while this plugin could be extended to include this iOS API, it won't actually work until one of two things happens:

  1. Microsoft updates its iOS Firebase bindings.
  2. This plugin migrates away from Microsoft's iOS Firebase bindings.
AdamEssenmacher commented 6 months ago

This should be fixed with 3.0.0