【发布时间】:2019-03-15 02:45:47
【问题描述】:
根据文档,我需要重新验证尝试删除其帐户但有一段时间未登录的用户。这是doc(最底部):
文档
如果您执行了其中一项操作,并且用户登录时间过长 以前,该操作因错误而失败。当这件事发生时, 通过从 用户并将凭据传递给 reauthenticateWithCredential
var user = firebase.auth().currentUser;
var credential;
// Prompt the user to re-provide their sign-in credentials
user.reauthenticateAndRetrieveDataWithCredential(credential).then(function() {
// User re-authenticated.
})
凭证?
我的问题在于从用户那里获取新的登录凭据部分。凭证变量应该具有什么值?根据Puff's comment here,它应该去:
var credential = firebase.auth.EmailAuthProvider.credential(email, password);
我的问题:电子邮件和密码来自哪里?由于我使用的是 GoogleSignInAuth,因此可以使用 firebase.auth().currentUser.email 检索电子邮件,因此它看起来像这样:
var user = firebase.auth().currentUser;
let credential = firebase.auth.GoogleAuthProvider.credential(firebase.auth().currentUser.email);
user.reauthenticateAndRetrieveDataWithCredential(credential).then(() => {
// User re-authenticated.
});
但我收到一个错误:
{"error":{"code":400,[{"message":"无法解析谷歌 id_token:qmnofficial@gmail.com", "domain":"global","reason":"invalid"}]}}
请帮忙。
【问题讨论】:
标签: angular firebase firebase-authentication