completeMfaLogin method

Future<AuthResponse> completeMfaLogin({
  1. required String code,
  2. required String ticket,
})

Complete an MFA login using a time-based one-time password.

This is only necessary if the user has MFA enabled.

code is the OTP generated by the user's password manager, and ticket is the AuthResponse.mfa.ticket returned by a preceding call to login.

Throws an ApiException if logging in via MFA fails.

https://docs.nhost.io/auth/api-reference#totp-login

Implementation

Future<AuthResponse> completeMfaLogin({
  required String code,
  required String ticket,
}) async {
  final res = await _apiClient.post<Session>(
    '/mfa/totp',
    data: {
      'code': code,
      'ticket': ticket,
    },
    responseDeserializer: Session.fromJson,
  );

  await setSession(res);
  return AuthResponse(session: res, user: res.user);
}