validatePassword method
Validate the current password
of the Firebase User
Implementation
Future validatePassword(String password) async {
try {
final authCredentials = EmailAuthProvider.credential(
email: firebaseAuth.currentUser?.email ?? '',
password: password,
);
final authResult = await firebaseAuth.currentUser
?.reauthenticateWithCredential(authCredentials);
return authResult?.user != null;
} catch (e) {
log?.e('Could not validate the user password. $e');
return FirebaseAuthenticationResult.error(
errorMessage: 'The current password is not valid.');
}
}