sendEmailVerification method

Future<bool> sendEmailVerification({
  1. required String accessToken,
  2. String? trueClientIP,
  3. String? trueClientIPKey,
  4. String? redirectUrl,
  5. String? returnToAfterEmailConfirmation,
  6. Locale? customLocale,
})

Request the verification of the email address of a profile. If there is an email address configured in the profile that was not already verified, sends an email to verify it.

Returns a bool that indicates if the email was sent (false if the email was already verified).

Parameters:

  • accessToken - Considering authToken a valid OAuth token, accessToken is authToken.accessToken.
  • trueClientIP - An optional header field; IP to protect requests from the backend. Note: For more details, see Identity Fraud Protection.
  • trueClientIPKey - An optional header field; the secret that must match the True-Client-IP-Key generated in the ReachFive console. Note: For more details, see Identity Fraud Protection.
  • redirectUrl - The URL sent in the verification email to which the profile is redirected. This URL must be whitelisted in the Allowed Callback URLs field of your ReachFive client settings.
  • returnToAfterEmailConfirmation - Returned in the redirect_url as a query parameter, this parameter is used as the post-email confirmation URL. It must be a valid URL.
  • customLocale - For any endpoint in this specification that generates an email or SMS, you can pass the Custom-Locale attribute as a header parameter.

Implementation

Future<bool> sendEmailVerification({
  required String accessToken,
  String? trueClientIP,
  String? trueClientIPKey,
  String? redirectUrl,
  String? returnToAfterEmailConfirmation,
  Locale? customLocale,
}) async {
  final sendEmailVerificationRequest = SendEmailVerificationRequest(
    redirectUrl: redirectUrl,
    returnToAfterEmailConfirmation: returnToAfterEmailConfirmation,
  );

  final authorization = 'Bearer $accessToken';

  final response = await emailApi.sendEmailVerification(
    authorization: authorization,
    trueClientIP: trueClientIP,
    trueClientIPKey: trueClientIPKey,
    sendEmailVerificationRequest: sendEmailVerificationRequest,
    customLocale: customLocale?.toLanguageTag(),
  );

  return response.data?.verificationEmailSent ?? false;
}