调用“验证您" Firebase应用程序的身份验证页面 [英] Invoke "Verify it's you" authentication page from a Firebase application

查看:106
本文介绍了调用“验证您" Firebase应用程序的身份验证页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Firebase应用程序中,用户可以删除其帐户.当您尝试删除帐户时,我想做与Google一样的事情:再次询问用户的密码.

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.

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

Is it possible to invoke this dialog using Firebase Auth API? Or in some other way?

推荐答案

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

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))...

如果要与Google供应商重新认证:

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))...

这篇关于调用“验证您" Firebase应用程序的身份验证页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆