resendEmailOtp method
Re-sends the one-time code for a pending email verification.
Implementation
Future<SendEmailOtpResult> resendEmailOtp(String verificationUuid, String email) async {
Future<SendEmailOtpResult> instrumentationOperation() async {
final operationScope = _state.flowScope.capture(replace: false);
await operationScope.ready();
if (!_state.initialized) {
throw DynamicStateException("call initialize() before using the client");
}
if (!(!_state.captchaRequired || (_state.captchaToken != null))) {
throw DynamicStateException("captcha token is required");
}
final captchaToken = _state.captchaToken;
operationScope.commit(() {
_state.captchaToken = null;
_state.captchaTokenChanged.emit(_state.captchaToken);
});
operationScope.check();
final retryEmailVerificationBody = <String, dynamic>{"verificationUUID": verificationUuid, "email": email};
if (captchaToken != null) retryEmailVerificationBody["captchaToken"] = captchaToken;
final retried = await _api.post<EmailVerificationCreateResponse>(path: "/emailVerifications/retry", body: retryEmailVerificationBody, token: _state.token, sessionPublicKey: _state.sessionPublicKey, parse: EmailVerificationCreateResponse.fromJson);
operationScope.check();
return SendEmailOtpResult(email: email, verificationUuid: retried.verificationUuid);
}
return await _api.instrumentation.runAsync("auth.resendEmailOtp", instrumentationOperation);
}