login method

Future<UserModel> login(
  1. UserModel credentials
)

Logs a user in to the Form.io project.

Sends a POST /user/login request with the user's email and password.

On success, returns a UserModel with the JWT token and user ID populated.

Example:

final user = UserModel(email: 'test@example.com', password: '1234');
final response = await authService.login(user);

Throws DioError on failure (invalid credentials, server error, etc).

Implementation

Future<UserModel> login(UserModel credentials) async {
  final response = await client.dio.post('/user/login', data: credentials.toLoginJson());
  return UserModel.fromJson(response.data as Map<String, dynamic>);
}