Invoke “Verify it's you” authentication page from a Firebase application

北战南征 提交于 2019-12-24 20:17:48

问题


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

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