There are a lot of court decisions that say they can, and none of those have been changed.
What happened here is
A. he was leaving the country, not entering it.
B. they confiscated his laptop for an extended period of time, moved it, searched it, etc.
"It is true that Kim’s laptop was seized at the border – in this case, LAX – but it was not even opened, much less searched, there. It was transported approximately 150 miles to San Diego, it was retained for a limited period of time, and eventually, the laptop was returned."
They can't do that :)