Alterar senha Firebase Flutter
Here's the latest method to change the password in firebase futter 2022
Future<bool> _changePassword(String currentPassword, String newPassword) async {
bool success = false;
//Create an instance of the current user.
var user = await FirebaseAuth.instance.currentUser!;
//Must re-authenticate user before updating the password. Otherwise it may fail or user get signed out.
final cred = await EmailAuthProvider.credential(email: user.email!, password: currentPassword);
await user.reauthenticateWithCredential(cred).then((value) async {
await user.updatePassword(newPassword).then((_) {
success = true;
usersRef.doc(uid).update({"password": newPassword});
}).catchError((error) {
print(error);
});
}).catchError((err) {
print(err);
});
return success;
}
MicroProgramer