调用"验证它" Firebase应用程序中的身份验证页面

时间:2017-11-10 10:13:00

标签: firebase firebase-authentication google-authentication

在我的Firebase应用程序中,用户可以删除他们的帐户。我想做同样的事情,当您尝试删除帐户时Google会这样做:再次询问用户的密码。

是否可以使用Firebase Auth API调用此对话框?或者用其他方式?

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以要求用户重新进行身份验证。这实际上是某些敏感操作的常见做法,例如删除Firebase用户,更新密码或电子邮件。您将重新进行身份验证并检查新ID令牌中的auth_time是否是最近的。 所以要在JS中用电子邮件/密码重新认证:

firebase.auth().currentUser.reauthenticateWithCredential(firebase.auth.EmailAuthProvider.credential(email, password))...

如果您想重新认证Google提供商:

var customParams = {login_hint: firebase.auth().currentUser.email, prompt: 'consent'};
firebase.auth().currentUser.reauthenticateWithPopup(new firebase.auth.GoogleAuthProvider().setCustomParameters(customParams))...