Adjust connection logic to ensure authentication