I can easily use this to create a user:
this.af.auth.createUser({email: email, password: password});
but how do I edit the users details once they're created? (ie: Change the password or the e-mail address?). I would think something like this:
this.af.auth.updateUser({email: email, password: password});
But there's no updateUser
method?
With AngularFire2 you just need to add "currentUser" to your path.
this.af.auth.currentUser.updateEmail(email)
.then(() => {
...
});
You will also need to reauthenticate the login prior to calling this as Firebase requires a fresh authentication to perform certain account functions such as deleting the account, changing the email or the password.
For the project I just implemented this on, I just included the login as part of the change password/email forms and then called "signInWithEmailAndPassword" just prior to the "updateEmail" call.
To update the password just do the following:
this.af.auth.currentUser.updatePassword(password)
.then(() => {
...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With