authenticateEmail method

  1. @override
Future<Session> authenticateEmail({
  1. String? email,
  2. String? username,
  3. required String password,
  4. bool create = false,
  5. Map<String, String>? vars,
})
override

Implementation

@override
Future<model.Session> authenticateEmail({
  String? email,
  String? username,
  required String password,
  bool create = false,
  Map<String, String>? vars,
}) async {
  assert(email != null || username != null);
  assert(create == false || email != null);

  final res = await _api.v2AccountAuthenticateEmailPost(
    body: ApiAccountEmail(
      email: email,
      password: password,
      vars: vars,
    ),
    create: create,
    username: username,
  );

  if (res.body == null) {
    throw Exception('Authentication failed.');
  }

  final data = res.body!;

  return model.Session.fromApi(data);
}