getCurrentUser method

Future<UserDetails> getCurrentUser({
  1. UserCredentials? userCredentials,
  2. EventStoreClientOperationOptions? operationOptions,
})

Gets the UserDetails of the internal user given by UserCredentials.username. If userCredentials is not provided, EventStoreClientSettings.defaultCredentials in settings is used. If UserCredentials.username is empty, an ArgumentOutOfRangeException is thrown.

Implementation

Future<UserDetails> getCurrentUser({
  UserCredentials? userCredentials,
  EventStoreClientOperationOptions? operationOptions,
}) {
  return $runRequest<UserDetails>(() async {
    final username =
        (userCredentials ?? settings.defaultCredentials)?.username;
    if (username?.isNotEmpty == false) {
      throw ArgumentOutOfRangeException(
        'username is not provided',
      );
    }

    final request = $a.DetailsReq()
      ..options = (DetailsReq_Options()..loginName = username!);
    final client = await $getClient();
    final response = client.details(
      request,
      options: $getOptions(
        userCredentials: userCredentials,
        operationOptions: operationOptions,
      ),
    );
    return _toUserDetails(
      await response.single,
    );
  });
}