Actually I'm working on a Ionic 2 application which is connected to my firebase backend. When I try to change the password of the actual user everything works fine, but the problem is that the promise, to change the password, is called twice.
I call the function in my editscreen:
changePassword() {
if(this.passwordchangeForm.valid) {
this.auth.changePasswort(this.passwordnew.value, this.password.value).then(data=>{
let toast = this.toastCtrl.create({
message: "Passwort erfolgreich geändert",
})
toast.present();
}).catch(error=>{
let alert = this.alertCtrl.create({
title: 'Fehler beim ändern des Passworts',
message: error,
buttons: ['OK']
})
alert.present();
})
}
}
Which calls the method changePassword() in my authprovider
changePasswort(passNew, password){
var currUser = this.firebase.auth().currentUser;
return new Promise((resolve, reject) =>{
this.loginWithEmail({email: currUser.email, password: password}).subscribe(data =>{
currUser.updatePassword(passNew).then(result =>{
resolve("Passwort Updated")
}).catch(error =>{
reject(error)
})
}, error=>{
reject(error);
})
})
}
If everything is correct the password is changed and the Toast is presented, if not the error shows up. But the problem is that everything pops up 2 or 3 times.
Someone of you can help me to fix that?