authWithPassword<T> method

  1. @override
Future<T> authWithPassword<T>({
  1. required String identity,
  2. required String password,
  3. String? expand,
  4. String? fields,
})
override

Implementation

@override
Future<T> authWithPassword<T>({
  required String identity,
  required String password,
  String? expand,
  String? fields,
}) async {
  try {
    Client client = Client(
      baseUrl,
      collectionName: collectionName,
      path: "/api/collections/${collectionName}/auth-with-password",
      expand: expand,
      fields: fields,
    );
    Map user = await client.post<Map>(body: {
      "identity": identity,
      "password": password,
    });
    Storage storage = Storage();
    await storage.setAuth(
        token: user['token'],
        id: user['record']['id'],
        userData: user['record']);
    return user as T;
  } catch (e) {
    rethrow;
  }
}