reauthenticate method

Future<AuthResultStatus?> reauthenticate(
  1. {required String email,
  2. required String password}
)

Reauthenticate a user using EmailAuthProvider

Handles FirebaseAuthExceptions using AuthExceptionHandler. Returns a AuthResultStatus for further processing.

Implementation

Future<AuthResultStatus?> reauthenticate({
  required String email,
  required String password,
}) async {
  try {
    final AuthCredential credential =
        EmailAuthProvider.credential(email: email, password: password);
    await instance.currentUser!.reauthenticateWithCredential(credential);
    if (instance.currentUser != null) {
      return AuthResultStatus.successful;
    } else {
      return AuthResultStatus.undefined;
    }
  } on FirebaseAuthException catch (e) {
    // Use AuthExeptionHandler to handle error codes
    return handleExeption(e);
  }
}