Firebase - email没有定义



我正在尝试构建一个允许用户更改密码的函数。问题是当我获得当前用户的数据时,它显示电子邮件为空。

一切都在Firebase上工作,用户在Firebase认证系统中创建。

这是我的一部分代码

reauthenticate = (currentPassword) => {
var user = firebase.auth().currentuser;
var cred = firebase.auth.EmailAuthProvider.credential(user.email, currentPassword);
user.reauthenticateWithCredential(cred);
}
reauthenticate(currentPassword).then(() => {
var user = firebase.auth().currentuser;
user.updatePassword(newPassword).then(() => {
alert("Password changed");
window.location.replace("./index.html");
}).catch((error) => {
console.log(error);
})
});

控制台显示的是Uncaught TypeError: Cannot read properties of undefined (reading 'email') at reauthenticate (password.js:15:64) at changePassword (password.js:27:9)

它的currentUser不是currentUser。资本美国

const user = firebase.auth().currentUser;

最新更新