更新firebase的密码

时间:2018-03-22 14:57:01

标签: javascript firebase firebase-authentication angularfire2

我想在角度ts中添加更改firebase密码的功能。在我的组件中,我调用从提交按钮更改密码的功能。

passwordChange(form: NgForm) {
const npassword = form.value.npassword;
const rpassword = form.value.rpassword;

if(npassword == rpassword){
this.authService.passwordChangeUser(npassword);

}
else{
alert("Password didnt match!");
}

}

从这个组件中调用我的authService函数passwordChangeUser,其参数为npassword(新密码)。这是我的authService.ts

  passwordChangeUser(npassword : string ){
  var user = firebase.auth().currentUser;

   user.updatePassword(npassword).then(function() {
     this.router.navigate(['/dashboard']);
     alert("successfully added!");
   console.log("successfully added!");
    }).catch(function(error) {
   console.log("unsuccessfull");
  alert("unsuccessful");
  });
 }

但这总是让我失望。它不会更新密码。我不知道是什么问题。请帮我,我如何更新我的密码。任何帮助将不胜感激谢谢。

0 个答案:

没有答案