This has to be determined based on house rules set before the game. If there are no rules in place, the player should be warned, possibly asked not to continue playing... but it should not affect the current hand.
Here is what most common house rules state:
"If a player exposes BOTH of their cards before all players have acted, the cards are shown to the table and that player can NO LONGER bet or raise. Their only options are call or fold. "
Because the player is already all-in, there should not be any action taken against the player. It is unfortunate, but mistakes happen. If it is suspected to be intentional, rather than a mistake, then I would ask that player to finish the hand and leave the game (or not return to future games). If it was intentional, the player could potentially be trying to save player 3 from losing their chips (if they are friends). Most likely though, this was just an accident and should be treated as such.
Those quoted house rules are from:
https://www.worldtavernpoker.info/complete-rule-guide