getUserWithID method

Future<User> getUserWithID({
  1. required User user,
})

Retrieves a User object, including the user's ID, based on the provided User object.

This method logs in the user using their existing information (e.g., username and password) and retrieves the full User object, including their ID.

  • user: The User object for which to retrieve the ID.

Returns the updated User object with the ID if successful.

Throws an exception if the login fails or the user data cannot be retrieved.

Implementation

Future<User> getUserWithID({required User user}) async {
  ApiReturn loginReturn =
  await _apiConnector.getUserRepo().loginUsingUser(user: user);
  if (loginReturn.success) {
    return loginReturn.data as User;
  } else {
    throw Exception(
      "Could not get ID of User ${loginReturn.returnCode}: ${loginReturn.explanation}",
    );
  }
}