message: feat(origin-organization-irec-api): user can recreate irec connection now
diff: @@ -39,6 +39,27 @@ export class CreateConnectionHandler implements ICommandHandler<CreateConnection
  throw new BadRequestException('IREC Registration not found');
  }
  + const existingConnection = await this.repository.findOne({
  + where: { registration: registration.id }
  + });
  +
  + if (existingConnection) {
  + if (userName !== existingConnection.userName) {
  + throw new BadRequestException('IREC connection user name mismatch');
  + }
  +
  + existingConnection.clientId = clientId;
  + existingConnection.clientSecret = clientSecret;
  + existingConnection.expiryDate = loginResult.expiryDate;
  + existingConnection.accessToken = loginResult.accessToken;
  + existingConnection.refreshToken = loginResult.refreshToken;
  + existingConnection.active = true;
  + existingConnection.attempts = 0;
  +
  + await existingConnection.save();
  +
  + return ConnectionDTO.wrap(existingConnection);
  + } else {
  const connection = await this.repository.save({
  ...loginResult,
  userName,
  @@ -47,8 +68,10 @@ export class CreateConnectionHandler implements ICommandHandler<CreateConnection
  clientSecret
  });
  - this.eventBus.publish(new ConnectionCreatedEvent(connection, organizationId, registration));
  -
  + this.eventBus.publish(
  + new ConnectionCreatedEvent(connection, organizationId, registration)
  + );
  return ConnectionDTO.wrap(connection);
  }
  }
  +}
  