checkActionCode method

  1. @override
Future<Either<AuthServiceActionCodeFailure, ({String? email})>> checkActionCode(
  1. String oobCode
)
override

Check (without consuming) a Firebase out-of-band action code — e.g. an email-verification oobCode from a verification deep link — and return the action's payload.

Use this BEFORE applyActionCode when you need the action's email or operation context. applyActionCode consumes the code; subsequent calls to checkActionCode with the same code return AuthServiceActionCodeFailure.invalidCode.

The returned email is the address the action was issued for (e.g. the pending verification target). May be null for operations that don't carry an email payload.

Implementation

@override
Future<Either<AuthServiceActionCodeFailure, ({String? email})>> checkActionCode(
  String oobCode,
) async {
  try {
    logd('checkActionCode: Checking action code');
    final info = await _fbAuth.checkActionCode(oobCode);
    final email = info.data['email'] as String?;
    logd('checkActionCode: Action code valid; email=$email');
    return right((email: email));
  } on fb_auth.FirebaseAuthException catch (e) {
    loge(e, 'checkActionCode failed');
    return left(_mapActionCodeException(e));
  } catch (e) {
    loge(e, 'checkActionCode failed');
    return left(AuthServiceActionCodeFailure.unexpected);
  }
}