问题
In my Firebase application users can remove their accounts. I want to do the same thing which Google do when you're trying to remove your account: ask the user's password once more.
Is it possible to invoke this dialog using Firebase Auth API? Or in some other way?
回答1:
You can ask the user to reauthenticate. This is actually common practice for certain sensitive operations like deleting a Firebase user, updating a password or email. You would reauthenticate and check the auth_time
in the new ID token is recent.
So to reauthenticate with email/password in JS:
firebase.auth().currentUser.reauthenticateWithCredential(firebase.auth.EmailAuthProvider.credential(email, password))...
If you want to reauthenticate with a Google provider:
var customParams = {login_hint: firebase.auth().currentUser.email, prompt: 'consent'};
firebase.auth().currentUser.reauthenticateWithPopup(new firebase.auth.GoogleAuthProvider().setCustomParameters(customParams))...
来源:https://stackoverflow.com/questions/47220366/invoke-verify-its-you-authentication-page-from-a-firebase-application