gpt4 book ai didi

javascript - firebase reauthenticateWithCredential 和 signInWithCustomToken

转载 作者:行者123 更新时间:2023-12-03 03:45:03 29 4
gpt4 key购买 nike

我使用 signInWithCustomToken 方法通过来自另一个应用的重定向在我的单页应用中建立登录。

在我的 SPA 中,我想让用户通过 currentUser.updatePassword(newPassword) 设置密码。除非用户需要重新验证,否则这工作正常:

important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and then call firebase.User#reauthenticateWithCredential.

我还没有找到使用自定义 token 重新进行身份验证的方法。我错过了什么吗?

最佳答案

是的,没有 reauthenticateWithCustomToken。您需要再次执行自定义 token 登录过程(如果您使用某些不受支持的提供商,请使用该提供商登录并创建新的自定义 token ),确认 UID 与之前的用户匹配,因为您不想切换用户。然后,您对新用户调用 updatePassword。

您可以在使用新的自定义 token 登录用户的过程中实例化新的 Firebase 应用,如果 UID 匹配,则只需在原始身份验证实例中使用相同的自定义 token (可重复使用直至过期)进行 SignInWithCustomToken然后对更新后的 currentUser 调用 updatePassword。

关于javascript - firebase reauthenticateWithCredential 和 signInWithCustomToken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45436668/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com