authWithPassword method
Authenticate an auth record by its username/email and password and returns a new auth token and record data.
On success this method automatically updates the client's AuthStore.
Implementation
Future<RecordAuth> authWithPassword(
String usernameOrEmail,
String password, {
String? expand,
String? fields,
Map<String, dynamic> body = const {},
Map<String, dynamic> query = const {},
Map<String, String> headers = const {},
}) {
final enrichedBody = Map<String, dynamic>.of(body);
enrichedBody["identity"] = usernameOrEmail;
enrichedBody["password"] = password;
final enrichedQuery = Map<String, dynamic>.of(query);
enrichedQuery["expand"] ??= expand;
enrichedQuery["fields"] ??= fields;
return client
.send(
"$baseCollectionPath/auth-with-password",
method: "POST",
body: enrichedBody,
query: enrichedQuery,
headers: headers,
)
.then((data) => _authResponse(data as Map<String, dynamic>? ?? {}));
}