angular - 使用 updatePassword 启用密码更改并重新验证 (Firebase+Angular)
问题描述
我想允许在我正在构建的网站上更改密码。我使用了来自stackoverflow的信息和我在互联网上看到的信息,在使用updatePassword
推荐的功能之前reauthenticate
,来验证用户的身份。以下功能对我不起作用,您知道为什么吗?
auth_state: any = null;
constructor(private firebaseAuth: AngularFireAuth) {
this.firebaseAuth.auth_state.subscribe((auth =>{
this.auth_state= auth;
}))
}
changePassword(new_password) {
var credentials = this.auth_state.prototype.reauthenticateWithCredential.EmailAuthProvider.credential("email@example.com", "oldPassword");
this.auth_state.prototype.reauthenticate(credentials)
.then(() => {
this.auth_state.prototype.updatePassword(new_password)
.then(() => {
})
.catch((error) => {
console.log(error);
})
})
.catch((error) => {
console.log(error);
})
}
我得到的错误是:
ERROR TypeError: Cannot read property 'reauthenticateWithCredential' of undefined