简体   繁体   English

firebase reauthenticateWithCredential和signInWithCustomToken

[英]firebase reauthenticateWithCredential and signInWithCustomToken

i use the signInWithCustomToken method to establish a login in my single page app through a redirect from another app. 我使用signInWithCustomToken方法通过从另一个应用程序的重定向在我的单页应用程序中建立登录。

in my SPA i would like to let the user set it's password via currentUser.updatePassword(newPassword) . 在我的SPA中,我想让用户通过currentUser.updatePassword(newPassword)设置密码。 this works fine unless the user needs to re-authenticate: 除非用户需要重新验证,否则此方法工作正常:

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. 重要:这是一项安全敏感的操作,要求用户最近登录。如果不满足此要求,请要求用户再次进行身份验证,然后调用firebase.User#reauthenticateWithCredential。

i have not found a method to use the custom-token to reauthenticate. 我尚未找到使用自定义令牌进行重新认证的方法。 did i miss something? 我错过了什么?

Yeah, there is no reauthenticateWithCustomToken. 是的,没有reauthenticateWithCustomToken。 You would need to go through the custom token sign in process again (if you are using some unsupported provider, sign in with that provider and mint a new custom token), confirm the UID matches the previous user as you don't want to switch the user. 您将需要再次执行自定义令牌登录过程(如果使用的是不受支持的提供程序,请使用该提供程序登录并创建一个新的自定义令牌),并确认UID与先前的用户匹配,因为您不想进行切换用户。 You then call updatePassword on the new user. 然后,您在新用户上调用updatePassword。

You can instantiate a new Firebase app in the process where you sign in the user with the new custom token, if the UIDs match, then just signInWithCustomToken with the same custom token (reusable until it is expired) in the original auth instance and then call updatePassword on the updated currentUser. 您可以在使用新的自定义令牌登录用户的过程中实例化一个新的Firebase应用程序(如果UID匹配),则只需在原始auth实例中使用具有相同自定义令牌(可重复使用,直到过期)的signInWithCustomToken,然后调用更新的currentUser上的updatePassword。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase:通过 REST 获取令牌并使用 signInWithCustomToken - Firebase: Getting a token via REST and using signInWithCustomToken 类型错误:无法使用 firebase reauthenticateWithCredential 读取未定义的属性“凭据” - TypeError: Cannot read property 'credential' of undefined with firebase reauthenticateWithCredential Firebase currentUser.getIdToken() 在 signInWithCustomToken 之后返回自定义令牌 - Firebase currentUser.getIdToken() returns custom token after signInWithCustomToken firebase 身份验证:signInWithCustomToken 和 createSessionCookie - 错误 auth/invalid-id - firebase authentication: signInWithCustomToken and createSessionCookie - error auth/invalid-id firebase.auth.signInWithCustomToken不是功能node.js - firebase.auth.signInWithCustomToken is not a function node.js 如何创建 Firebase web user.reauthenticateWithCredential() 方法所需的“凭据”对象? - How to create “credential” object needed by Firebase web user.reauthenticateWithCredential() method? 尝试使用signInWithCustomToken进行身份验证并出现奇怪的错误 - Trying to authenticate with signInWithCustomToken with strange errors Firebase身份验证,firebase未定义 - Firebase authentication, firebase is not defined Firebase功能 - Firebase functions Firebase 没有定义? - Firebase is not defined?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM