verifyOtpLoginCode method

Future<EmailAccountOtpVerificationResult> verifyOtpLoginCode(
  1. Session session, {
  2. required UuidValue otpLoginRequestId,
  3. required String verificationCode,
  4. Transaction? transaction,
})

Verifies a one-time password and returns a token to complete the login.

If EmailAccountOtpVerificationResult.accountExists is true, pass the token to finishOtpLogin to sign in. Otherwise, have the user accept the terms (and optionally set a password if EmailAccountOtpVerificationResult.allowPassword is true) and pass it to finishOtpRegistration to create the account.

Throws an EmailAccountRequestException in case of errors, with reason:

Implementation

Future<EmailAccountOtpVerificationResult> verifyOtpLoginCode(
  Session session, {
  required UuidValue otpLoginRequestId,
  required String verificationCode,
  Transaction? transaction,
}) async {
  return DatabaseUtil.runInTransactionOrSavepoint(
    session.db,
    transaction,
    (transaction) => EmailIdpUtils.withReplacedServerEmailException(
      () => utils.otpLogin.verifyOtpLoginCode(
        session,
        otpLoginRequestId: otpLoginRequestId,
        verificationCode: verificationCode,
        transaction: transaction,
      ),
    ),
  );
}