【问题标题】:Invoke "Verify it's you" authentication page from a Firebase application从 Firebase 应用程序调用“验证它是你”身份验证页面
【发布时间】:2018-04-23 12:57:54
【问题描述】:

在我的 Firebase 应用程序中,用户可以删除他们的帐户。当您尝试删除您的帐户时,我想执行与 Google 相同的操作:再次询问用户密码。

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

【问题讨论】:

    标签: firebase firebase-authentication google-authentication


    【解决方案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))...
    

    【讨论】:

      猜你喜欢
      • 2018-12-23
      • 2018-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-11
      • 2018-01-24
      • 2014-01-26
      • 2018-12-29
      相关资源
      最近更新 更多