如何创建“凭据"Firebase web user.reauthenticateWithCredential() 方法需要的对象? [英] How to create "credential" object needed by Firebase web user.reauthenticateWithCredential() method?

查看:10
本文介绍了如何创建“凭据"Firebase web user.reauthenticateWithCredential() 方法需要的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新文档:

var user = firebase.auth().currentUser;
var credential;
// Prompt the user to re-provide their sign-in credentials
user.reauthenticateWithCredential(credential).then(function() {

我应该如何创建这个 credential 对象?

How should I create this credential object?

我试过:

  • reauthenticateWithCredential(email, password)(类似登录方式)
  • reauthenticateWithCredential({ email, password })(文档只提到一个参数)
  • reauthenticateWithCredential(email, password) (like the login method)
  • reauthenticateWithCredential({ email, password }) (the docs mention one argument only)

没有运气:(

PS:我不计算在新文档中搜索相关信息所浪费的时间……我非常想念 firebase.com 的精彩文档,但我想切换到 v3 或更高版本的 firebase.storage...

推荐答案

我设法让它发挥作用,应该更新文档以包含此内容,适用于不想在详尽但难以理解的问题上花费太多时间的人- 阅读 API 参考.

I managed to make it work, docs should be updated to include this for who does not want to spend too much time in the exhaustive-but-hard-to-read API reference.

凭证对象是这样创建的:

The credential object is created like so:

const user = firebase.auth().currentUser;
const credential = firebase.auth.EmailAuthProvider.credential(
    user.email, 
    userProvidedPassword
);
// Now you can use that to reauthenticate
user.reauthenticateWithCredential(credential);

这篇关于如何创建“凭据"Firebase web user.reauthenticateWithCredential() 方法需要的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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