register method

  1. @override
Future<RegisterResponse> register({
  1. String? username,
  2. String? password,
  3. String? deviceId,
  4. String? initialDeviceDisplayName,
  5. bool? inhibitLogin,
  6. bool? refreshToken,
  7. AuthenticationData? auth,
  8. AccountKind? kind,
})

Checks to see if a username is available, and valid, for the server. Returns the fully-qualified SDN user ID (MXID) that has been registered. You have to call checkNode first to set a node.

Implementation

@override
Future<RegisterResponse> register({
  String? username,
  String? password,
  String? deviceId,
  String? initialDeviceDisplayName,
  bool? inhibitLogin,
  bool? refreshToken,
  AuthenticationData? auth,
  AccountKind? kind,
}) async {
  final response = await super.register(
    kind: kind,
    username: username,
    password: password,
    auth: auth,
    deviceId: deviceId,
    initialDeviceDisplayName: initialDeviceDisplayName,
    inhibitLogin: inhibitLogin,
  );

  // Connect if there is an access token in the response.
  final accessToken = response.accessToken;
  final deviceId_ = response.deviceId;
  final userId = response.userId;
  final node = this.node;
  if (accessToken == null || deviceId_ == null || node == null) {
    throw Exception(
        'Registered but token, device ID, user ID or node is null.');
  }

  await init(
      newToken: accessToken,
      newUserID: userId,
      newNode: node,
      newDeviceName: initialDeviceDisplayName ?? '',
      newDeviceID: deviceId_);
  return response;
}