javascript - 如何在 Firebase 中重新授权用户?
问题描述
环境
- Firebase JavaScript SDK v8
问题
如何使用密码重新授权已登录的用户?我想做的是如下:
const password = "some-password"
firebase.reAuthorizeUser(password)
.then(() => console.log("ok"))
.catch(() => console.log("ng"))
先感谢您。
解决方案
你正在寻找reauthenticateWithCredential
方法。
const user = firebase.auth().currentUser;
// TODO(you): prompt the user to re-provide their sign-in credentials
const credential = promptForCredentials();
user.reauthenticateWithCredential(credential).then(() => {
// User re-authenticated.
}).catch((error) => {
// An error ocurred
// ...
});
Checkout在文档中重新验证用户。
推荐阅读
- ios - Swift:UICollection 的水平滚动非常慢
- asp.net - 在 asp.net 中执行母版页时出现以下错误
- javascript - 如何使用 HTML 表单发送电子邮件并使用 Node.js 和 Gulp 提交?
- android - 如果显示所有组件并且 Android API 27 中还有空间,则 onClick 事件在 LinearLayout 中不起作用
- javascript - 表单提交表单验证 false
- pandas - 如何在 Bokeh 工具提示中用“-”替换 %NaN
- sql-server - 如何使用当前用户的凭据运行 Set-SqlNetworkConfiguration
- javascript - Firebase 未在 iOS Ionic 上初始化
- kubernetes - kubeadm 加入失败,http://localhost:10248/healthz 连接被拒绝
- java - Java - 如何处理大量团队?(Bukkit 插件)