sendSignInLinkToEmail method

  1. @override
Future<bool> sendSignInLinkToEmail({
  1. required String email,
})
override

Implementation

@override
Future<bool> sendSignInLinkToEmail({required String email}) async {
  final MonitoringService monitoringService = core.get<MonitoringService>();
  var trace =
      await monitoringService.createTrace(name: 'sendSignInLinkToEmail');
  trace.start();
  try {
    if (!isReady) {
      throw LittlefishFirebaseAuthException('AUTH_INIT_000',
          '$providerName: Firebase is not initialized, $providerName cannot send sign in link to email');
    }

    logger.debug(
      this,
      "$providerName: Sending sign in link to email $email",
    );

    //ToDo: Implement the action code settings
    await kInstance?.sendSignInLinkToEmail(
      email: email,
      actionCodeSettings: ActionCodeSettings(
        url: "https://www.example.com/?email=$email",
        handleCodeInApp: true,
      ),
    );

    logger.info(
      this,
      "$providerName: Sign in link sent to email $email",
    );

    return true;
  } on FirebaseAuthException catch (e) {
    throw _handleFirebaseAuthException(e);
  } catch (e) {
    if (e is LittlefishException) {
      rethrow;
    }
    throw LittlefishFirebaseAuthException(
      'AUTH_014',
      'An unexpected error occurred while sending sign in link to email.',
      cause: e,
    );
  } finally {
    trace.stop();
  }
}