问题
I'm building an app that uses firebase auth (and firestore database) but only facebook login.
The user only has to login once with my app and from then on when they continue to open the app I check
if Auth.auth().currentUser != nil
{
}
And so if there is a logged in user already then i don't make them re-login.
But when they want to delete their account from the app the error message pops:
Error Domain=FIRAuthErrorDomain Code=17014 "This operation is sensitive and requires recent authentication. Log in again before retrying this request." UserInfo={NSLocalizedDescription=This operation is sensitive and requires recent authentication. Log in again before retrying this request., error_name=ERROR_REQUIRES_RECENT_LOGIN}
Do I really need to get the user to login again? Because that means i'll have to get them to re-login with facebook and sending them back to fb's page so they can delete their account seems overkill. Is there a token I can just back to confirm login?
This is possibly a separate question...but when i deleted the user directly from firebase console so there were no users left in the system I'm pretty sure from the app sitting on the client
Auth.auth().currentUser was not nil and still contained the uid of the users account that i deleted. Not entirely sure why that is.
Thanks.
回答1:
This is done for security reasons. Reauthentication is a sensitive operation. Same as when you try to update your password (you need to enter the old one), update your email, update a credit card, shipping address for an e-commerce app, etc. It may not be convenient but it is necessary for the user's security.
For good practice, you should enforce this. However, if you need to delete a user from your server, you can always use Admin SDK admin.auth().deleteUser(uid)
API: https://firebase.google.com/docs/auth/admin/manage-users#delete_a_user
Separately, you need to either reload
the user or try to refresh the token getIDToken
to force it to detect the deletion of the user.
来源:https://stackoverflow.com/questions/47725265/firautherrordomain-code-17014-error-when-deleting-from-firebase-auth-b-c-not-re