authenticateEmail method

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

Implementation

@override
Future<model.Session> authenticateEmail({
  required String email,
  required String password,
  bool create = true,
  String? username,
  Map<String, String>? vars,
}) async {
  final res = await _api.nakamaAuthenticateEmail(
    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(
    created: data.created ?? false,
    token: data.token!,
    refreshToken: data.refreshToken,
  );
}