【问题标题】:How to reauthorize a user in Firebase?如何在 Firebase 中重新授权用户?
【发布时间】:2021-08-24 03:29:19
【问题描述】:
环境
- Firebase JavaScript SDK v8
问题
如何使用密码重新授权已登录的用户?我想做的如下:
const password = "some-password"
firebase.reAuthorizeUser(password)
.then(() => console.log("ok"))
.catch(() => console.log("ng"))
提前谢谢你。
【问题讨论】:
标签:
javascript
firebase
firebase-authentication
【解决方案1】:
您正在寻找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
// ...
});
在文档中结帐reauthenticate a user。
【解决方案2】:
const credential = promptForCredentials();
这给了我错误
找不到变量:promptForCredentials。