【发布时间】:2018-04-23 12:57:54
【问题描述】:
在我的 Firebase 应用程序中,用户可以删除他们的帐户。当您尝试删除您的帐户时,我想执行与 Google 相同的操作:再次询问用户密码。
是否可以使用 Firebase Auth API 调用此对话框?还是以其他方式?
【问题讨论】:
标签: firebase firebase-authentication google-authentication
在我的 Firebase 应用程序中,用户可以删除他们的帐户。当您尝试删除您的帐户时,我想执行与 Google 相同的操作:再次询问用户密码。
是否可以使用 Firebase Auth API 调用此对话框?还是以其他方式?
【问题讨论】:
标签: firebase firebase-authentication google-authentication
您可以要求用户重新进行身份验证。这实际上是某些敏感操作的常见做法,例如删除 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))...
【讨论】: