Firebase에서 사용자를 재 인증하는 방법에 대한 도움을 주시면 감사하겠습니다. 설명서에이 기능을 사용하는 방법이 설명되어 있지 않은 경우 위의 모든 기능을 추가하는 것이 의미가 있는지 궁금합니다.Firebase reauthenticate 사용하기
현재이 작업을 시도하고 있으며 작동하지 않습니다. 생성자에서 cannot read property 'credential' of undefined
같은 오류 :
constructor(@Inject(FirebaseApp) firebaseApp: any) {
this.auth = firebaseApp.auth();
console.log(this.auth);
}
reauthenticate()
방법이 없다 firebase.auth.Auth 자체에, firebase.User에서 호출
changePassword(passwordData) {
if(passwordData.valid) {
console.log(passwordData.value);
// let us reauthenticate first irrespective of how long
// user's been logged in!
const user = this.auth.currentUser;
const credential = this.auth.EmailAuthProvider.credential(user.email, passwordData.value.oldpassword);
console.log(credential);
this.auth.reauthenticate(credential)
.then((_) => {
console.log('User reauthenticated');
this.auth.updatePassword(passwordData.value.newpassword)
.then((_) => {
console.log('Password changed');
})
.catch((error) => {
console.log(error);
})
})
.catch((error) => {
console.log(error);
})
}
}
해결할 수 있었습니까? 나는 같은 문제에 직면 해있다. –
@MK_Dev 당신은 프랭크의 대답을 시도 했습니까? auth 대신 reauthenticate를 호출해야합니다. 어쩌면 지금은 효과가있을 것입니다. – Rexford
실제로 작동했습니다. EmailAuthProvider가 정의되지 않은 동일한 문제가 발생했습니다. 내가해야 할 일은 무엇이든간에 "캐스트"파이어베이스였습니다. var fb : any = firebase; var credential = fb.auth.EmailAuthProvider.credential (email, password); –